Welcome, Guest. Please Login or Register.
Nov 24th, 2024, 10:38pm

Home Home Help Help Search Search Members Members Login Login Register Register
Arimaa Forum « Rating of opponents in open games »


   Arimaa Forum
   Arimaa
   Bot Development
(Moderator: supersamu)
   Rating of opponents in open games
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Rating of opponents in open games  (Read 2033 times)
Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Rating of opponents in open games
« on: Aug 20th, 2012, 5:53am »
Quote Quote Modify Modify

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 ...
IP Logged

Janzert
Forum Guru
*****



Arimaa player #247

   


Gender: male
Posts: 1016
Re: Rating of opponents in open games
« Reply #1 on: Aug 20th, 2012, 11:36am »
Quote Quote Modify Modify

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
IP Logged
Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Re: Rating of opponents in open games
« Reply #2 on: Aug 20th, 2012, 3:50pm »
Quote Quote Modify Modify

May be one should at first sit to the game as visitor.
IP Logged

Janzert
Forum Guru
*****



Arimaa player #247

   


Gender: male
Posts: 1016
Re: Rating of opponents in open games
« Reply #3 on: Aug 20th, 2012, 5:18pm »
Quote Quote Modify Modify

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
IP Logged
Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Re: Rating of opponents in open games
« Reply #4 on: Aug 20th, 2012, 5:51pm »
Quote Quote Modify Modify

on Aug 20th, 2012, 5:18pm, 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 Wink
IP Logged

Janzert
Forum Guru
*****



Arimaa player #247

   


Gender: male
Posts: 1016
Re: Rating of opponents in open games
« Reply #5 on: Aug 21st, 2012, 12:44pm »
Quote Quote Modify Modify

on Aug 20th, 2012, 5:51pm, Hippo wrote:

May be this is why it fails Wink

 
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
IP Logged
Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Re: Rating of opponents in open games
« Reply #6 on: Aug 21st, 2012, 12:51pm »
Quote Quote Modify Modify

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 Smiley.
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 ...
« Last Edit: Aug 21st, 2012, 4:23pm by Hippo » IP Logged

Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Re: Rating of opponents in open games
« Reply #7 on: Aug 22nd, 2012, 5:07am »
Quote Quote Modify Modify

I got it Wink
 
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.
« Last Edit: Aug 22nd, 2012, 8:26am by Hippo » IP Logged

Janzert
Forum Guru
*****



Arimaa player #247

   


Gender: male
Posts: 1016
Re: Rating of opponents in open games
« Reply #8 on: Aug 22nd, 2012, 11:02am »
Quote Quote Modify Modify

Congratz, getting close. Smiley
 
Janzert
IP Logged
Hippo
Forum Guru
*****




Arimaa player #4450

   


Gender: male
Posts: 883
Re: Rating of opponents in open games
« Reply #9 on: Aug 22nd, 2012, 3:25pm »
Quote Quote Modify Modify

Openning of the closest bot in rating is not difficult at all Wink.
 
So I would probably let bot_Hippo to open games for itself.
IP Logged

Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

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