Topic: Python XChat Play Bot

Hello again.
Going to try one more time to attach the file here,
I'm open to any advice if this doesn't work again.

Just a reminder, this is not a finished product.
Any and all suggestions and improvements are welcomed,
however, I am not a professional programmer or even
that great with python, so do not expect improvements
to be made in any timely manner.

On the other hand, I am releasing this script as public domain,
and waive any rights to it. So feel free to tweak it however
you wish.

Thanks,
AG420

Thumbs up Thumbs down

2 (edited by agentgreen420 2012-05-06 03:42:30)

Re: Python XChat Play Bot

Well, call me crazy, but it looks like my attachment failed again.
Let me know of any preferred method of distribution.

EDIT: For now, you may download from TinyUpload.com
http://tinyurl.com/c7qa69w

Thumbs up Thumbs down

Re: Python XChat Play Bot

Just tried this on x-chat aqua the mac version of x-chat and it fails to load.

  File "/Users/leonbeech/Downloads/playbot_v1.py", line 123
      except urllib2.URLError as detail:
                               ^
  SyntaxError: invalid syntax
  Error loading module /Users/leonbeech/Downloads/playbot_v1.py

Thumbs up +1 Thumbs down

4 (edited by agentgreen420 2012-05-06 03:40:59)

Re: Python XChat Play Bot

RussellB-
First off, thanks for testing!

It is likely that this issue is happening because MacOS often comes with an older version of python installed.
In Python 2.6, I believe, the exception syntax was altered to use the keyword "as"

This issue can be easily resolved by editing the source at line 123.
Simply replace the word "as" with a single comma.

EDIT: Changed code, link. reDL if you wish.

Thanks again, and sorry for any inconvenience.
-AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

It now appears in the plugin list but how am I meant use it.

I have tried /login name password

But that comes up with an error.

Which version of python do you recommend using 2.7 or 3.2

Thumbs up Thumbs down

Re: Python XChat Play Bot

Hello again.
"/login name password" is the correct command to start the script.
I have so far tested only with Python 2.7.2+
It would be helpful if you could paste the error message somewhere.
Thank you,
-AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

Traceback (most recent call last):
    File "/Users/leonbeech/Downloads/playbot_v1-1.py", line 71, in login
      usecommand("login {0} {1}".format(name, pswd) )
  AttributeError: 'str' object has no attribute 'format'

Thumbs up Thumbs down

Re: Python XChat Play Bot

I have now got the script working with X-Chat Azure which is an updated version of x-chat aqua.  So I'm testing it now

Thumbs up Thumbs down

Re: Python XChat Play Bot

The bot does work.  The only real problem is it doesn't calculate the bestfights correctly, it doesn't account for hero and alignment in the calculations and thinks everybody is aligned human with no hero.

Thumbs up Thumbs down

10 (edited by agentgreen420 2012-06-13 19:46:49)

Re: Python XChat Play Bot

^^^ This is very true.
Although, I thought I was calculating fights correctly, since I virtually always arrive at the same results as Elfstar

DISCLAIMER***
I am very new to this game, and do not know all optimum strategies.
I do not know exactly how heroes and alignments affect fights, so I did ignore them.
I was just creating this bot as an interesting project to help me learn Python.
This code is not complete, it is more of a jumping-off point for anyone who might be interested in taking it further.
As such, I do not plan on giving any further support.

However, if you folks can give me any in depth info on improvements, I would be interested in attempting to implement them.

This code is hereby released under the WTFPL, do whatever u want with it.
And thanks for trying it out!
AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

http://idlerpg.org/minimal/players.php

Is a player table with alignment and hero on it which shows how it can alter your final item score.

Human = 0 adjustment
priest = +10% adjustment
undead = -10% adjustment

Hero depending on what level it is can be +2% to +11% onto your score.

Thumbs up Thumbs down

Re: Python XChat Play Bot

Heres a small update with new code to adjust sums based on alignment and hero statuses.
http://tinyurl.com/796753p

Cheers
-AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

I have tested the update and the bets are not being calculated correctly now.  All bets should be calculated on an human alignment and no hero basis.  So you would need to use 2 different lists, 1 adjusted for fights and 1 normal for bets.

Thumbs up Thumbs down

Re: Python XChat Play Bot

http://tinyurl.com/c68gvvm
^^ hacked to fix issue

@RussellB, if you have time to discover a bug, why not take a whack at patching it?

Thumbs up Thumbs down

Re: Python XChat Play Bot

The bestfight is broken now giving high item score players.

This is my fix for the bestfight/bestbet.  It is not pretty but it works.

Post's attachments

playbot_v2-3.py 10.2 kb, 6 downloads since 2012-06-28 

You don't have the permssions to download the attachments of this post.

Thumbs up Thumbs down

16 (edited by agentgreen420 2012-06-30 07:37:39)

Re: Python XChat Play Bot

Sorry! bestfight broke again due to a bug on line 185 (now on 187). Fixed now, plus added a feature made to buy item. Currently buys all level 30 items as soon as you have 900 gols and are over lvl 15, unless sum is already over 300.

http://tinyurl.com/cj2rl58

Lemme know if u have any other modifications or suggestions. Thanks!
AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

3 problems with the script at the moment are:

Level up timer,  This is doesn't always work, 1 of the causes is fighting a random star which has a fixed time off per level which can cause you to level up before any level up timer is issued.  So it needs to be able to detect if fights and bets are less than 5 to do it elsewhere.  Fights can also be effected if you drop a level which will reset your fights to 0.  Also if you win the Champions League tournament your bets will be reset to 0

The other problem is due to a bug in the gamebot which will log you out if it leaves the channel and doesn't log you back in when it returns.  So the script needs to be able to detect if you are offline to relog you back in.

I have tried adding these myself but due to lack of knowledge of python it always fails.

The next problem is if website data is not fully downloaded and only part of the data is downloaded the script will die.

Thumbs up Thumbs down

18 (edited by agentgreen420 2012-07-09 15:19:30)

Re: Python XChat Play Bot

I have attempted to add these features, but as these mostly deal with random occurances, I haven't been able to test them all yet, so. Plz test! Every interval, the bot should check if youre online, and if not, login; it will check if you can fight or bet, and if so do it. And I also added a condition that will hopefully fix the partial data problem, but idk.

http://tinyurl.com/7f238ge
-AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

Log back in if not online fails

Traceback (most recent call last):
    File "/Users/leonbeech/Downloads/playbot_v3.py", line 152, in main
      login(None)
  TypeError: login() takes exactly 3 arguments (1 given)

The easiest way to test log back in if not online is to logout and wait for the interval to come.

Thumbs up Thumbs down

20 (edited by agentgreen420 2012-07-10 04:01:44)

Re: Python XChat Play Bot

http://tinyurl.com/cvqzsqk
^^ fixes
Should address the above error, and a bug that made you try to fight and bet twice in a row

AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

The partial read from website causes the script to quit.  This is the error which comes up from my own modified version of your script.

  Traceback (most recent call last):
    File "/Users/leonbeech/Downloads/playbot_v1-21.py", line 170, in main
      rawplayers3 = text.read()
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 351, in read
      data = self._sock.recv(rbufsize)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 541, in read
      return self._read_chunked(amt)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 592, in _read_chunked
      value.append(self._safe_read(amt))
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 649, in _safe_read
      raise IncompleteRead(''.join(s), amt)
  httplib.IncompleteRead: IncompleteRead(1957 bytes read, 6180 more expected)

I'm trying a fix for it, I will post it if it works.

Thumbs up Thumbs down

Re: Python XChat Play Bot

I've had no success in fixing this yet.

Thumbs up Thumbs down

Re: Python XChat Play Bot

I've fixed this problem

Post's attachments

playbot_v3-3.py 10.07 kb, 7 downloads since 2012-09-11 

You don't have the permssions to download the attachments of this post.

Thumbs up Thumbs down

Re: Python XChat Play Bot

This fix has been incorporated, thanks dude!
AG420

Thumbs up Thumbs down

Re: Python XChat Play Bot

New Release

Mostly bug fixes but there are a few game play changes and team support has been added.

Post's attachments

playbot_v3-4.py 10.95 kb, 9 downloads since 2013-09-30 

You don't have the permssions to download the attachments of this post.

Thumbs up Thumbs down