Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> Bot Development >> Rating of opponents in open games
(Message started by: Hippo on Aug 20th, 2012, 5:53am)

Title: Rating of opponents in open games
Post by Hippo on Aug 20th, 2012, 5:53am
Does anybody know how could bot look at the ratings of players of open games to use it for the decission which game to sit to?

I would prefere to change the regime ... playing random game opened by a bot to playing game opened by a bot with closest rating to my rating.

Oh there is one more question, how can bot find it's own rating before it sits to a game?

I have looked at the response to "openGames" frome gameroom.py and there is just opponent name, even the opponent Id is missing. On the contrary the html generated includes the required info ...

Title: Re: Rating of opponents in open games
Post by Janzert on Aug 20th, 2012, 11:36am
Unfortunately in quite a few areas the human client API from the server gives quite a bit more information than the bot API. In this case the only information the server gives to a bot client is timecontrol, side, created time, player name, rated and game id.

On the other hand I wouldn't be surprised if bot accounts were allowed access through the human client API (I've never tried it though). The human client API is actually (at least partially) documented in a thread here on the forums somewhere and isn't too different from the bot API. I used it as a starting reference to understand the bot API when writing the AEI gameroom interface.

Janzert

Title: Re: Rating of opponents in open games
Post by Hippo on Aug 20th, 2012, 3:50pm
May be one should at first sit to the game as visitor.

Title: Re: Rating of opponents in open games
Post by Janzert on Aug 20th, 2012, 5:18pm
It's been a few (or would that be several?) years now since I was really deep in the bot API that the server provides. But from what I recall it doesn't provide a way for a bot to view or otherwise join a game as a visitor/observer. So even that would require going through the human client API.

Janzert

Title: Re: Rating of opponents in open games
Post by Hippo on Aug 20th, 2012, 5:51pm

on 08/20/12 at 17:18:10, Janzert wrote:
It's been a few (or would that be several?) years now since I was really deep in the bot API that the server provides. But from what I recall it doesn't provide a way for a bot to view or otherwise join a game as a visitor/observer. So even that would require going through the human client API.

Janzert


May be this is why it fails ;)

Title: Re: Rating of opponents in open games
Post by Janzert on Aug 21st, 2012, 12:44pm

on 08/20/12 at 17:51:19, Hippo wrote:
May be this is why it fails ;)


Not sure what 'this' and 'it' refer to, so I'm rather missing the sentence meaning altogether.

But I'm also not sure there's anything else I can add to the subject. The only way I see of making this happen is for you to go through the human client API as it has so many more capabilities.

Janzert

Title: Re: Rating of opponents in open games
Post by Hippo on Aug 21st, 2012, 12:51pm
Thanks for help. I would try some experiments with human interface... . It reffered to my experiments with sitting to the game as visitor.


Code:
   url = 'http://arimaa.com/arimaa/gameroom/playerpage.cgi?id=12492'
   req = urllib2.Request(url)
   filehandle = urllib2.urlopen(req)

   cnt = 0
   rating = 0
   for line in filehandle.readlines():
       if cnt>0:
           cnt+=1
       if (">Rating<" in line):
           cnt=1
       if (cnt==3):
           rating = int(line[0:line.find(";")])


First small result ... here is my bot's rating :).
Just to find translation from the bot's name to the id...

http://arimaa.com/arimaa/gameroom/searchPlayers.cgi
would be helpful, just the cookie is needed ...

Title: Re: Rating of opponents in open games
Post by Hippo on Aug 22nd, 2012, 5:07am
I got it ;)


Code:
def rating(bot_username,bot_password,player_name):

   cj = cookielib.CookieJar()
   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
   url = 'http://arimaa.com/arimaa/gameroom/login.cgi'

   values = {'email' : bot_username,
         'password' : bot_password,
         'value' : 'enter' }
   data = urllib.urlencode(values)
   opener.open(url,data)
   
   url = 'http://arimaa.com/arimaa/gameroom/searchPlayers.cgi'
   values = {'any' : player_name}
   data = urllib.urlencode(values)

   filehandle = opener.open(url,data)
   for line in filehandle.readlines():
       if ('>'+player_name+'<' in line):
           at = line.find("id=")+3
           len = line[at:at+20].find("'")
           id = line[at:at+len]

   filehandle.close()

   url = 'http://arimaa.com/arimaa/gameroom/playerpage.cgi?id='+id
   req = urllib2.Request(url)
   filehandle = urllib2.urlopen(req)

   cnt = 0
   rating = 0
   for line in filehandle.readlines():
       if cnt>0:
           cnt+=1
       if (">Rating<" in line):
           cnt=1
       if (cnt==3):
           rating = int(line[0:line.find(";")])

   filehandle.close()
   return rating


So the next step is to open corresponding bot from the ladder ..., but it would be better to do it only when there is small number of running games.

Title: Re: Rating of opponents in open games
Post by Janzert on Aug 22nd, 2012, 11:02am
Congratz, getting close. :)

Janzert

Title: Re: Rating of opponents in open games
Post by Hippo on Aug 22nd, 2012, 3:25pm
Openning of the closest bot in rating is not difficult at all ;).

So I would probably let bot_Hippo to open games for itself.



Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.