Author Topic: [ANN] AutoHunter - a Python botting framework  (Read 20014 times)

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
[ANN] AutoHunter - a Python botting framework
« on: August 06, 2014, 06:59:54 AM »
Finally, I want to announce the availability of my own botting framework in Python: AutoHunter!  You can find the code at https://www.gitorious.org/autohunter/autohunter/ and more information about it in the README file (see https://www.gitorious.org/autohunter/autohunter/source/README).  Everything is free software under the AGPLv3, and the scripts connect to a local daemon via the RPC interface.  You don't have to compile anything, just run a Python script.

Features:
  • No need to worry about the actual RPC interface.
  • Get high-level information about the game state via an object-oriented interface.
  • The framework handles player creation (name_new and name_firstupdate) transparently for you.
  • You can focus on implementing your own strategies without having to worry about technicalities.
  • Strategies can be developed on various levels depending on your needs; you can just make use of the basic framework and write everything on your own, or you can implement abstract "behaviours" and have the framework automatically assign individual hunters to your behaviour, auto-create them on death and so on.

Also, the framework includes ready-to-use simple "example bots".  They can be used with minimal configuration and without programming knowledge, and have functionality roughly equivalent to BGB's Qt bot (basic gathering).  In addition, there are bots included to "run" after a disaster for the crown and coins on the ground.  You can use my very basic logic and extend it with your own ideas to make the bots more intelligent - and you can share your behaviours, so that others can build upon them and combine them together.

I did a "live test" during the current disaster (see also the README file), and was able to get quite some coins (240+ and there are still two hunters out gathering) with just the basic logic included in the repository and only four hunters.  One of them even briefly held the crown (so now I'm one of the crown holders in Huntercoin's history, too :D), but was killed quickly since I didn't implement any defensive strategies.  You can also see the gathering bots' behaviour live on test-net.

If you like my work here, I'll appreciate any donations to my address in the signature. ;)  Also, feel free to contact me if you have suggestions, want to share your own behaviours or whatever.  I may also be available for contract development according to your needs - let me know if you are interested in doing something advanced with the framework!
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

Snailbrain

  • Developer
  • Hero Member
  • *****
  • Posts: 1001
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #1 on: August 06, 2014, 10:23:18 AM »
Finally, I want to announce the availability of my own botting framework in Python: AutoHunter!  You can find the code at https://www.gitorious.org/autohunter/autohunter/ and more information about it in the README file (see https://www.gitorious.org/autohunter/autohunter/source/README).  Everything is free software under the AGPLv3, and the scripts connect to a local daemon via the RPC interface.  You don't have to compile anything, just run a Python script.

Features:
  • No need to worry about the actual RPC interface.
  • Get high-level information about the game state via an object-oriented interface.
  • The framework handles player creation (name_new and name_firstupdate) transparently for you.
  • You can focus on implementing your own strategies without having to worry about technicalities.
  • Strategies can be developed on various levels depending on your needs; you can just make use of the basic framework and write everything on your own, or you can implement abstract "behaviours" and have the framework automatically assign individual hunters to your behaviour, auto-create them on death and so on.

Also, the framework includes ready-to-use simple "example bots".  They can be used with minimal configuration and without programming knowledge, and have functionality roughly equivalent to BGB's Qt bot (basic gathering).  In addition, there are bots included to "run" after a disaster for the crown and coins on the ground.  You can use my very basic logic and extend it with your own ideas to make the bots more intelligent - and you can share your behaviours, so that others can build upon them and combine them together.

I did a "live test" during the current disaster (see also the README file), and was able to get quite some coins (240+ and there are still two hunters out gathering) with just the basic logic included in the repository and only four hunters.  One of them even briefly held the crown (so now I'm one of the crown holders in Huntercoin's history, too :D), but was killed quickly since I didn't implement any defensive strategies.  You can also see the gathering bots' behaviour live on test-net.

If you like my work here, I'll appreciate any donations to my address in the signature. ;)  Also, feel free to contact me if you have suggestions, want to share your own behaviours or whatever.  I may also be available for contract development according to your needs - let me know if you are interested in doing something advanced with the framework!

Epic - can't wait to set it up.

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #2 on: August 06, 2014, 12:11:08 PM »
Epic - can't wait to set it up.

Cool!  Let me know about your experiences - I'm pretty sure that there are still a lot of rough edges.  Also, of course, use at your own risk (not just you but everyone who wants to give it a shot).  But, as I said, for me it seems to be working quite well so far.  And if you want to see them in action, look at the gatherers in test-net.  Feel free to kill them or whatever to trigger the regeneration mechanism and (hopefully) see it work.
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

dbaum

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #3 on: August 07, 2014, 02:02:27 AM »
Can you give a little guidance on how to get this set up and going?

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #4 on: August 07, 2014, 06:11:47 AM »
Can you give a little guidance on how to get this set up and going?

See in the included README file - I've tried to write some basics in there.  But basically, what you need to do is this:

1) Check out the code from the linked Git repository.
2) Ensure that you have an RPC daemon running, either by using huntercoind or huntercoin-qt with the "server=1" option in your huntercoin.conf file.
3) Edit "mainGather.py" and change at least the RPC connection settings (port most probably 8399 for main-net, as well as your username/password found in the huntercoin.conf file) and the name prefix you want to use (replacing my "domob-").
4) Ideally and if you are motivated to do so, adapt the gatherer-configurations (there're some comments about it directly in the source).  This may boost the performance if you use good values (and possibly change them from time to tim).
5) Run "mainGather.py" and keep it running - watch the output to check that everything is ok.

If you kill the process (or it crashes), it will usually resume operation where it left off.  Data is stored in "gather.state".  If you don't want this (because you changed some parameters, for instance, and want to restart completely), remove the file.  Note that this removes information about some pending operations (in particular, name_new rand values), so be careful!  But in general it should be able to cope with restarts also, where it will simply use hunters existing already in your wallet and pick one for each gatherer you want to run (instead of recreating them).
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

inkha

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #5 on: August 07, 2014, 08:02:14 PM »
all hail the soulmaster. XD
this is great man, thanks for releasing it.
Pretty code to!

zy0n

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • GithubHUCRepo
Re: [ANN] AutoHunter - a Python botting framework
« Reply #6 on: August 09, 2014, 05:51:06 AM »
So I figured I'd give it a test go... [modifies proper variables]
script creates 7 unusable players (long names)
Soooo you should probably add a check in there somewhere so this doesn't happen again to someone else.




HUC: HJHB5CLKStCfZjWxEcXsoMT4dEL7oNSP6k

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #7 on: August 09, 2014, 08:02:28 AM »
So I figured I'd give it a test go... [modifies proper variables]
script creates 7 unusable players (long names)
Soooo you should probably add a check in there somewhere so this doesn't happen again to someone else.

Can you give me more details?  The script should create names with exactly ten characters, and they should work fine.  I've never seen anything matching your description, although I'm not sure I fully understood what exactly goes wrong.  But if you can provide more details, I would love to investigate what the problem is!
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

zy0n

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • GithubHUCRepo
Re: [ANN] AutoHunter - a Python botting framework
« Reply #8 on: August 09, 2014, 08:08:24 AM »
So I figured I'd give it a test go... [modifies proper variables]
script creates 7 unusable players (long names)
Soooo you should probably add a check in there somewhere so this doesn't happen again to someone else.

Can you give me more details?  The script should create names with exactly ten characters, and they should work fine.  I've never seen anything matching your description, although I'm not sure I fully understood what exactly goes wrong.  But if you can provide more details, I would love to investigate what the problem is!


Code: [Select]
Status: 98 confirmations
Date: 8/9/2014 00:24
Name operation: name_new: 1303868f13842fe791ae46f68c6aa78d8ca9eb21
Debit: -10.00 HUC
Net amount: -10.00 HUC
Transaction ID: 8b2703713d3807e414abb13021dd8a04182f139c7c008c55cc97f1e00bf34247

Status: 98 confirmations
Date: 8/9/2014 00:24
Name operation: name_new: fcc688d314865dab1df617280d6f9fe2081ae6dd
Debit: -10.00 HUC
Net amount: -10.00 HUC
Transaction ID: b9b20438a5a4da16e3ded7423bf1c4d6672fce12a1fc889f041f58726e8bcbe8


The code is creating thesenames... its got about 10 of them now :(
HUC: HJHB5CLKStCfZjWxEcXsoMT4dEL7oNSP6k

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #9 on: August 09, 2014, 08:44:00 AM »
These look like ordinary "name_new" transactions (although created from the RPC) - so nothing invalid about the name.  The question is, however, why it creates the name_new's and doesn't name_firstupdate them.  How exactly are you using the code, just the "mainGather.py" file?  Or something else?

Note that these names probably aren't lost - you should find the necessary "rand" value to activate the players (at worst manually) both in the debug prints of the script and also in your debug.log (I think).
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

zy0n

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • GithubHUCRepo
Re: [ANN] AutoHunter - a Python botting framework
« Reply #10 on: August 09, 2014, 09:29:51 AM »
These look like ordinary "name_new" transactions (although created from the RPC) - so nothing invalid about the name.  The question is, however, why it creates the name_new's and doesn't name_firstupdate them.  How exactly are you using the code, just the "mainGather.py" file?  Or something else?

Note that these names probably aren't lost - you should find the necessary "rand" value to activate the players (at worst manually) both in the debug prints of the script and also in your debug.log (I think).

You don't see the extraordinarily long name after name_new do you? Because the name is too long the game wont handle it.
Is there a way to re-name an already named character?
« Last Edit: August 09, 2014, 09:40:25 AM by zy0n »
HUC: HJHB5CLKStCfZjWxEcXsoMT4dEL7oNSP6k

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #11 on: August 09, 2014, 06:52:16 PM »
If you mean these: 1303868f13842fe791ae46f68c6aa78d8ca9eb21, I still believe they are ok.  I think that name_new transactions don't display the actual name in the Qt if you did them via RPC.  This is not the name, it is not too long and it should be fine.  Really. :)

If you want, you can try to issue a "name_new" command (on test-net?) on the command-line and should see that it looks the same.
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu

Mithril Man

  • Hero Member
  • *****
  • Posts: 589
    • View Profile
    • Mithril Man Web!
Re: [ANN] AutoHunter - a Python botting framework
« Reply #12 on: August 09, 2014, 10:22:06 PM »
on my client I've the same long string next to name_new, no problem at all, that's some kind of hash, not the name you have registered (it's weird and bad looking but it's fine)
Alternative GUI client for Huntercoin http://www.mithrilman.com
HUC donation: HMSCYGYJ5wo9FiniVU4pXWGUu8E8PSmoHE
BTC donation: 1DKLf1QKAZ5njucq37pZhMRG67qXDP3vPC

zy0n

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • GithubHUCRepo
Re: [ANN] AutoHunter - a Python botting framework
« Reply #13 on: August 10, 2014, 08:48:23 PM »
If you mean these: 1303868f13842fe791ae46f68c6aa78d8ca9eb21, I still believe they are ok.  I think that name_new transactions don't display the actual name in the Qt if you did them via RPC.  This is not the name, it is not too long and it should be fine.  Really. :)

If you want, you can try to issue a "name_new" command (on test-net?) on the command-line and should see that it looks the same.

Code: [Select]
INFO:root:We have 0 reserve players, 0 in registration and 0 being activated.
Traceback (most recent call last):
  File "C:\Users\charl_000\Documents\GitHub\autohunter\mainGather.py", line 64, in <module>
    if controller.persist ("gather.state"):
  File "C:\Users\charl_000\Documents\GitHub\autohunter\controller.py", line 228, in persist
    control.loop (strategy)
  File "C:\Users\charl_000\Documents\GitHub\autohunter\controller.py", line 256, in loop
    ok = strategy.play (self)
  File "C:\Users\charl_000\Documents\GitHub\autohunter\souls.py", line 288, in play
    h = s.getHunter ()
  File "C:\Users\charl_000\Documents\GitHub\autohunter\souls.py", line 72, in getHunter
    assert self.hunter.status in ["pending", "active"]
AssertionError


getting this every time it sends a move
and yeah i'll have to see whatsup with them, i have like 15 of them lol
HUC: HJHB5CLKStCfZjWxEcXsoMT4dEL7oNSP6k

domob

  • Developer
  • Sr. Member
  • *****
  • Posts: 285
    • View Profile
Re: [ANN] AutoHunter - a Python botting framework
« Reply #14 on: August 11, 2014, 06:50:40 AM »
Code: [Select]
INFO:root:We have 0 reserve players, 0 in registration and 0 being activated.
Traceback (most recent call last):
  File "C:\Users\charl_000\Documents\GitHub\autohunter\mainGather.py", line 64, in <module>
    if controller.persist ("gather.state"):
  File "C:\Users\charl_000\Documents\GitHub\autohunter\controller.py", line 228, in persist
    control.loop (strategy)
  File "C:\Users\charl_000\Documents\GitHub\autohunter\controller.py", line 256, in loop
    ok = strategy.play (self)
  File "C:\Users\charl_000\Documents\GitHub\autohunter\souls.py", line 288, in play
    h = s.getHunter ()
  File "C:\Users\charl_000\Documents\GitHub\autohunter\souls.py", line 72, in getHunter
    assert self.hunter.status in ["pending", "active"]
AssertionError


getting this every time it sends a move
and yeah i'll have to see whatsup with them, i have like 15 of them lol

AssertionError means that some situation occured that "should not" occur - i. e., it indicates (probably) that there's some bug in the code leading up to the line in question.  If you can reproduce the problem consistenly, can you send me your files so I can take a look and hopefully fix the problem?  I'd need all .py files you modified (configuration?), the gather.state and your wallet - if you don't want to send me the wallet, you can try to reproduce the problem on test-net or tell me how I can try to reproduce it there.
Use your Namecoin-ID as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | HBkxA5QmYSATFoPN1wFk8eBkgwPpY97Mfu