Author |
Topic: Rating of opponents in open games (Read 2033 times) |
|
Hippo
Forum Guru
Arimaa player #4450
Gender:
Posts: 883
|
|
Rating of opponents in open games
« on: Aug 20th, 2012, 5:53am » |
Quote 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:
Posts: 1016
|
|
Re: Rating of opponents in open games
« Reply #1 on: Aug 20th, 2012, 11:36am » |
Quote 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:
Posts: 883
|
|
Re: Rating of opponents in open games
« Reply #2 on: Aug 20th, 2012, 3:50pm » |
Quote Modify
|
May be one should at first sit to the game as visitor.
|
|
IP Logged |
|
|
|
Janzert
Forum Guru
Arimaa player #247
Gender:
Posts: 1016
|
|
Re: Rating of opponents in open games
« Reply #3 on: Aug 20th, 2012, 5:18pm » |
Quote 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:
Posts: 883
|
|
Re: Rating of opponents in open games
« Reply #4 on: Aug 20th, 2012, 5:51pm » |
Quote 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
|
|
IP Logged |
|
|
|
Janzert
Forum Guru
Arimaa player #247
Gender:
Posts: 1016
|
|
Re: Rating of opponents in open games
« Reply #5 on: Aug 21st, 2012, 12:44pm » |
Quote Modify
|
on Aug 20th, 2012, 5:51pm, 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
|
|
IP Logged |
|
|
|
Hippo
Forum Guru
Arimaa player #4450
Gender:
Posts: 883
|
|
Re: Rating of opponents in open games
« Reply #6 on: Aug 21st, 2012, 12:51pm » |
Quote 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 . 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:
Posts: 883
|
|
Re: Rating of opponents in open games
« Reply #7 on: Aug 22nd, 2012, 5:07am » |
Quote Modify
|
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.
|
« Last Edit: Aug 22nd, 2012, 8:26am by Hippo » |
IP Logged |
|
|
|
Janzert
Forum Guru
Arimaa player #247
Gender:
Posts: 1016
|
|
Re: Rating of opponents in open games
« Reply #8 on: Aug 22nd, 2012, 11:02am » |
Quote Modify
|
Congratz, getting close. Janzert
|
|
IP Logged |
|
|
|
Hippo
Forum Guru
Arimaa player #4450
Gender:
Posts: 883
|
|
Re: Rating of opponents in open games
« Reply #9 on: Aug 22nd, 2012, 3:25pm » |
Quote Modify
|
Openning of the closest bot in rating is not difficult at all . So I would probably let bot_Hippo to open games for itself.
|
|
IP Logged |
|
|
|
|