Huntercoin Forum

General Category => Bots => Topic started by: domob on August 06, 2014, 06:59:54 AM

Title: [ANN] AutoHunter - a Python botting framework
Post by: domob 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:

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!
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: Snailbrain 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.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: dbaum on August 07, 2014, 02:02:27 AM
Can you give a little guidance on how to get this set up and going?
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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).
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: inkha on August 07, 2014, 08:02:14 PM
all hail the soulmaster. XD
this is great man, thanks for releasing it.
Pretty code to!
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n 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.




Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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!
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n 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 :(
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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).
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n 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?
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: Mithril Man 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)
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n 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
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob 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.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n on August 12, 2014, 06:50:34 PM
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.
I can send you all the files I trust you, but that problem happened before I even modified anything.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on August 13, 2014, 07:21:16 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.
I can send you all the files I trust you, but that problem happened before I even modified anything.

This is really strange!  So you just changed your RPC parameters and then ran "mainGather.py" without any other modifications to get this?  Does anyone else see something similar?
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n on August 13, 2014, 10:51:45 PM
Code: [Select]
    if self.hunter.status not in ["pending", "active"]:
      logging.info("Hunter Error? : %s",self.hunter.status)
    assert self.hunter.status in ["pending", "active"]
added the if, problem stopped lol... it knows i'm watching!!!
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n on August 14, 2014, 02:55:18 AM
Code: [Select]
    if self.hunter.status not in ["pending", "active"]:
      logging.info("Hunter Error? : %s",self.hunter.status)
    assert self.hunter.status in ["pending", "active"]
added the if, problem stopped lol... it knows i'm watching!!!
didnt stop :P but it's saying the hunters are 'foreign'
Don't know if i'm following the flow correctly, but its not possible for
a hunter not owned by the wallet to even get to this stage in the code?

Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on August 14, 2014, 07:34:51 AM
Code: [Select]
    if self.hunter.status not in ["pending", "active"]:
      logging.info("Hunter Error? : %s",self.hunter.status)
    assert self.hunter.status in ["pending", "active"]
added the if, problem stopped lol... it knows i'm watching!!!
didnt stop :P but it's saying the hunters are 'foreign'
Don't know if i'm following the flow correctly, but its not possible for
a hunter not owned by the wallet to even get to this stage in the code?
Thanks for digging out this additional info!  It shouldn't be possible for a 'foreign' hunter to get there.  BTW, do you run huntercoind with the latest name_list fixes merged?  If not, this is the likely explanation.  There was a bug that made name_list incomplete, missing pending names.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: zy0n on August 14, 2014, 07:45:31 AM
Code: [Select]
    if self.hunter.status not in ["pending", "active"]:
      logging.info("Hunter Error? : %s",self.hunter.status)
    assert self.hunter.status in ["pending", "active"]
added the if, problem stopped lol... it knows i'm watching!!!
didnt stop :P but it's saying the hunters are 'foreign'
Don't know if i'm following the flow correctly, but its not possible for
a hunter not owned by the wallet to even get to this stage in the code?
Thanks for digging out this additional info!  It shouldn't be possible for a 'foreign' hunter to get there.  BTW, do you run huntercoind with the latest name_list fixes merged?  If not, this is the likely explanation.  There was a bug that made name_list incomplete, missing pending names.
I do not, I'll update my repo's right meoww!! Thanks!!
But I hotbypass-fixed it by just setting the 'foreign' to 'pending' manually
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: reaper on October 10, 2014, 09:29:21 AM
Is there a way to release player manual for Mainrunner? What happened was i ran the program with not enough coin in wallet, i shut it down,sent more coin to wallet,started it up and it remade the players it made before i closed it down the first time. Anyway the wallet freezes with debug stopping on method=gettransaction.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on October 10, 2014, 11:08:08 AM
Is there a way to release player manual for Mainrunner? What happened was i ran the program with not enough coin in wallet, i shut it down,sent more coin to wallet,started it up and it remade the players it made before i closed it down the first time. Anyway the wallet freezes with debug stopping on method=gettransaction.
It depends on your situation.  In principle, all state information should be saved persistently anyway - but it could have been that the error due to missing coins in the wallet (which is something I didn't implement it for, at least for now) crashed the daemon before it was able to save a consistent state.

However, all information necessary to activate hunters (the rand value returned by name_new, in particular) is written to the log precisely for this reason.  Do you have the logs still lying around?  If not, I think it should also be in your daemon's debug.log.  If you find the rand value and the txid, you can enable the hunter manually using the name_firstupdate command.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: reaper on October 10, 2014, 11:26:05 AM
Yes i got those and will try name_first update.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: reaper on October 10, 2014, 01:43:14 PM
Says ERROR: transaction rejected, coins already spent like a copy of wallet.dat. I got name, rand, and TXid from daemon log and added a value for transaction and got that error.What to put for <toaddress>or is it needed. If i try with no value it comes back ERROR: could not find coin with this name, try specifying the name_new txid. Also had a ERROR: there pending processes for this player. And had name_firstupdate fail on MM client for 4 players on another PC. I didn't try to make anymore players since. Wonder if these guys will be stuck in purgatory.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: Mithril Man on October 10, 2014, 01:53:48 PM
as i said in many places, we (players) are experiencing a lot of pending and double spending issue from some hours, no one know why
than sometimes stucked hunters from hours, start moving, weird...

no body has a clue of what's happening?
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on October 11, 2014, 11:26:41 AM
as i said in many places, we (players) are experiencing a lot of pending and double spending issue from some hours, no one know why
than sometimes stucked hunters from hours, start moving, weird...

no body has a clue of what's happening?

TBH, so far I don't know what the problem could be.  I didn't do any changes seem plausible to have caused this in recent times, and in particular as far as I heard, the problems have been starting since the last disaster.  (?)  There weren't any new commits for at least a week or so - because I'm waiting on snailbrain to test and merge my latest pending pull request.

My nodes also don't show me any "AcceptToMemoryPool" rejections, so it seems that they have no problems relaying transactions.  (But I'm no miner.)  Neither on 1.0.12 (chain.huntercoin.org) nor 1.0.13 (other nodes I'm running).
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: redbeans2012 on October 11, 2014, 12:38:05 PM
Seemed to start before disaster.  As I remember block times became really slow at one point.  Taking around 5 mins.  That's when the pending problem started.  It got worse for me after disaster.  I literally can't do anything.  Sometimes creating a new char works.  All my moves go to pnding
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: Mithril Man on October 11, 2014, 03:54:09 PM
Seemed to start before disaster.  As I remember block times became really slow at one point.  Taking around 5 mins.  That's when the pending problem started.  It hot worse for me after disaster.  I literally can't do anything.  Sometimes creating a new char works.  All my moves go to pnding

yes that's the timing, and this is why i reported here some thoughts https://github.com/chronokings/huntercoin/pull/85
it seems times match with changes, when he said:

Quote
wangchun commented a day ago
@MithrilMan Besides this patch, I also updated huntercoind to the latest github revision the day before yesterday, which caused a long rebuild of the block index.

maybe is just a coincidence...
would be nice to know which was the previous version they were running

edit:
domob do you know if miners were using your version that fixes the pending problem? if no, then maybe there is a chance your fix introduced a bug. could be possible?
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on October 11, 2014, 05:52:16 PM
domob do you know if miners were using your version that fixes the pending problem? if no, then maybe there is a chance your fix introduced a bug. could be possible?

I don't know.  Snailbrain manages the miner connections and all that.  Of course, there could be a bug.  So far I'm not aware of any - but I'm happy about any hints.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: reaper on October 12, 2014, 03:55:24 PM
When i run Mainrunner the wallet freezes after a few blocks, in debug it stops on method=gettransaction. Is this happening to anyone else.
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: jwinterm on March 10, 2015, 04:11:24 PM
So, I just created my first SimpleGather bot, and he seems to be working OK. I just edited the RPC settings, the name, and made it so only one bot is created, and he's off to gather some coins (only 10 at a time cause I forgot to edit that :/ ).

Anyway, my question is:
Is there any way to convert the simple gather bot to a simple runner bot if I happen to be around the computer when the disaster happens? Is this possible using this framework?

Edit: Also, is there a way to tell gather bot to go sit in the spawn area to recover the 200 HUC it cost to create him?

Thanks :)
Title: Re: [ANN] AutoHunter - a Python botting framework
Post by: domob on March 11, 2015, 07:25:53 AM
Thanks for your interest!  I'm glad that it seems to work for you so far - note that I haven't really updated the botting framework lately for the various game mechanics changes (since it seemed to me that noone was using it anyway).  To answer your questions, I think you can change the bot with some "manual hacks" but it is not something which is explicity implemented.  Also, it does not support recycling - but it may be worth adding recycling after a certain time after the last disaster (for instance).  It also does not yet support the "new style" name registration, which would allow to get rid of all that "reserved hunter" complication.

In any way, you can always just kill the bot process (at least if no pending name_new's are there) and manually play with the wallet to recycle or perform a disaster run or whatever.

Hopefully I'll be able to spend some time on this in the future to bring it up-to-date again.