Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> Bot Development >> Case-based bot
(Message started by: heroicjanitor on Mar 11th, 2011, 12:15pm)

Title: Case-based bot
Post by heroicjanitor on Mar 11th, 2011, 12:15pm
Hi I am trying to make a bot using my own case-based code, which just needs the game position to be given. I noticed that the sample java bot provided by Jeff Bacher, which I intend to use, searches a game tree and I was wondering if it would be easy to change that behaviour to use my own code(which I haven't completed yet). Basically I need to be given a position(in the same format as the game logs Ee5, Ce6 etc) and then after I analyse it,  I want to return a move, such as Ee5n. Is that feasible?

Title: Re: Case-based bot
Post by Fritzlein on Mar 11th, 2011, 12:22pm
Sure, it's feasible, but I'm not sure what you would be re-using from someone else's code except the interface to the game room to get a position and return a move.  You don't want a search tree, right?  In fact, it sounds like you don't even want to generate all possible moves, evaluate each resulting position, and pick the move with the highest evaluation, right?  Instead you want to look at the position and generate a move appropriate to that position?  For that you would be starting from scratch, because that's not how anyone else does it, as far as I know.

Or maybe I'm misreading your intention.  If what you want to do is evaluate positions in your own way, then I recall from looking at Don Dailey's sample bot it looked relatively easy to drop in an evaluation function and leave the search unchanged.

Title: Re: Case-based bot
Post by heroicjanitor on Mar 11th, 2011, 12:47pm

on 03/11/11 at 12:22:22, Fritzlein wrote:
Sure, it's feasible, but I'm not sure what you would be re-using from someone else's code except the interface to the game room to get a position and return a move.  You don't want a search tree, right?  In fact, it sounds like you don't even want to generate all possible moves, evaluate each resulting position, and pick the move with the highest evaluation, right?  Instead you want to look at the position and generate a move appropriate to that position?  For that you would be starting from scratch, because that's not how anyone else does it, as far as I know.

Or maybe I'm misreading your intention.  If what you want to do is evaluate positions in your own way, then I recall from looking at Don Dailey's sample bot it looked relatively easy to drop in an evaluation function and leave the search unchanged.


No you were correct, I pretty much just want to be given a position and return a move, I wasn't sure how much of the sample bot was required though. I am able to return the move I want to use when given a position by myself but I don't know how the interfacing to the game-room works. I don't generate all possible moves as you said, and as a bit of a coincidence you're the player my bot is supposed to be modelled after  ;D

Title: Re: Case-based bot
Post by Fritzlein on Mar 11th, 2011, 12:53pm
Since all you need help with is the interface, I don't think you will need anyone's sample bot.  Unfortunately, I have never gotten a bot running, so I can't help you further, but anyone who has a bot could.  I look forward to playing against my doppleganger!

Title: Re: Case-based bot
Post by heroicjanitor on Mar 25th, 2011, 9:56am
I've been trying to run the python scripts just to see what they do. gameroom.py gives back an error when I try to execute it as is, but I probably need to change things. I don't see how to get the aei to use stdio. Is it easy? It would be helpful if someone could just tell me what to do with the aei files. So far I think I should move the aei files to the same folder as my java bot and change the variables in it to reflect the name of my bot. Then run the gameroom.py script? Then how is the location of stdio specified? Confused :(

Title: Re: Case-based bot
Post by rbarreira on Mar 25th, 2011, 10:29am
There is no location for stdio, it just means "standard input/output".

All this means is that to communicate with AEI, your bot should print out commands as if it were printing to the screen (console). To get commands from AEI, it should read as if it wanted to get input from the console.

Title: Re: Case-based bot
Post by heroicjanitor on Mar 25th, 2011, 12:12pm
Yeah I know, but then I would just run the python scripts and make my code respond to stdio. But I thought that was separate for different programs? As in how does the python script know to look for the stdio from my particular program? If that makes sense, I am probably wrong about stdio though. If so then just running executing gameroom.py without editing shouldn't give me an error right? I have the latest python version, should I go back to the one aei was written in? Even though I amn't sure what version that would be.

Title: Re: Case-based bot
Post by rbarreira on Mar 25th, 2011, 1:11pm
The python script starts your program, so it can capture output from it and give input to it.

What is the error that you are getting? You can post your gameroom.cfg file too.

Title: Re: Case-based bot
Post by heroicjanitor on Mar 25th, 2011, 4:00pm
Yep :) This is the error I get(I am a complete novice at python so I don't know how to fix the syntax myself)

File "gameroom.py", line 87except urllib2.URLError, err:^SyntaxError: invalid syntax

The config file is


Code:
[global]
# Url of gameroom to connect to
gameroom_url = http://arimaa.com/arimaa/gameroom

# Minimum time for a move so we don't flood the server
min_move_time = 5

# Time left on the clock when bot controller will try to force the bot to reply
min_time_left = 9

# Directory for files to keep track of running bots
run_dir = ./running

# Maximum number of bots that can be active at one time
max_bots = 1

# bot section to use
default_engine = bot_example

[Logging]
# directory to write the log files to
directory = ./logs

# overall log level
# Valid levels are (in order of most to least verbose):
#   Debug
#   Info
#   Warning
#   Error
level = Debug

# log to the console (stdout) or not
console = True

# console log level
console_level = Debug

# level to log network information at
# setting this to debug will log every network message to and from the gameroom
# this is a large amount of data
net_level = Info

# level to log messages from the bot engine
engine_level = Debug

# level to log aei communication messages
aei_level = Info

# log the current position after every move
log_position = True

[bot_example]
# gameroom username
username = bot_example

# gameroom password
password = botspassword

# Method of communicating with the bot, options are stdio and socket.
communication_method = stdio

# command to run bot
cmdline = ./bot_example

# Greeting to send at the beginning of a game
greeting = Hi. I'm just a bot so don't try chatting with me.
   My handler is example writer. If you encounter any problems please notify <email address>
   Thank you for playing me and enjoy the game.

# timecontrol to start games at
#timecontrol = 30s/3/100/5/8
timecontrol = 60s/5m/75/0/4h/4m
#timecontrol = 1d/60d/100/0/300d/21d

# start rated games
rated = True

# should the bot think on opponents turn
# should probably be set to False when playing at a fixed depth
ponder = True

# options starting with bot_ are sent to configure the bot before starting play
# Size in MB for transition table
bot_hash = 200

# Maximum depth to search; in steps.
# bot_depth = 8


Actually now the way you said it kinda made me realise what was wrong. The problem being that there is no bot called bot_example... I stupidly thought it was a default thing to test if it works. So I can just use my username/password and I should be able to access the gameroom and play against it?

Title: Re: Case-based bot
Post by dree12 on Mar 25th, 2011, 8:48pm
What python version are you using? I think that might have something to do with it.

Title: Re: Case-based bot
Post by heroicjanitor on Mar 26th, 2011, 7:46am
I'm using version 3.2, it's the latest one.

Title: Re: Case-based bot
Post by Janzert on Mar 27th, 2011, 8:47am
Sorry, Python 3 is a new version of the language with several major backward incompatible changes. You'll need to use a Python 2 version for AEI, the most recent is 2.7.

Janzert

Title: Re: Case-based bot
Post by heroicjanitor on Mar 27th, 2011, 1:00pm
Ok it seems to be working now, thanks :)

Title: Re: Case-based bot
Post by heroicjanitor on Apr 5th, 2011, 5:49am
I decided to use the perl scripts provided instead so I only had to design the getMove program. I can't find it in the available bots section, but it is connecting to the gameroom and I can only find it through my bot's profile. When I click the sit link, it gives the following page:



Quote:
Temporarily Unavailable

Use the back button of your browser to return to the previous page.

Will be restored in a few minutes.

Temporarily Unavailable

Use the back button of your browser to return to the previous page.

Will be restored in a few minutes.

Temporarily Unavailable

Use the back button of your browser to return to the previous page.

Will be restored in a few minutes.

Expired Game

Use the back button of your browser to return to the previous page.

Cannot find the game id for this game.


This is the url of the popup page:
http://arimaa.com/arimaa/gameroom/opengamewin.cgi?client=1&gameid=undefined&role=undefined&side=undefined

Using the gameid the command line gives me and setting side=w, I can get into the game. It sometimes comes up on the command line that I have entered the game against my bot. Even though I am gold, I can't click start since it constantly says waiting. I can see the personalised message I told my bot to say at the start of each game. If I try to write back, it says I am not a player, yet if I look at the game from the outside it says heroicjanitor is playing vs bot_heroicjanitor. Any ideas as to what is wrong?

Title: Re: Case-based bot
Post by heroicjanitor on Apr 5th, 2011, 7:31am
UPDATE: I created a game myself and got the bot to join that. It was successful in joining me, I set up my pieces and on his turn he submitted an illegal move(no move) and the game ended. It seems to be a fluke since I can't get him to join again. Or do bots who submit illegal moves get banned?
EDIT: Ok he joined again... I think I just needed to sign in again.

Title: Re: Case-based bot
Post by heroicjanitor on Apr 5th, 2011, 10:27pm
I gave up and installed linux. It works now.

Title: Re: Case-based bot
Post by omar on Apr 5th, 2011, 11:48pm
Very strange. Off hand I don't know what might have caused this. Could be that the Perl on windows wasn't working quite the way the script expected it to.

Title: Re: Case-based bot
Post by Swynndla on Apr 14th, 2011, 7:50am

on 03/27/11 at 08:47:55, Janzert wrote:
Sorry, Python 3 is a new version of the language with several major backward incompatible changes. You'll need to use a Python 2 version for AEI, the most recent is 2.7.

Janzert

A side-note question if I may - If I were to write a bot in python3, then I think I'd be able to run the AEI in python2.7 even though my bot would run python3 (at the same time), right?  I'm assuming this because a bot can be written in any code, independant of the AEI, but I just wanted to check with others that I've got my thinking straight.

Title: Re: Case-based bot
Post by Janzert on Apr 14th, 2011, 1:34pm
Yep, AEI running under python 2.x with the bot running under python 3.x would be fine.

Janzert

Title: Re: Case-based bot
Post by heroicjanitor on May 1st, 2011, 9:09pm
Hi I have another question, I am trying to use the bot interface kit with my class written in java. It takes the position file and returns the move, as per the instruction, but when I change the bot.cfg file to point at the java file it doesn't work... As an example(even thought it would only work for the first move) I tried to use a Move class with a main method that prints out the setup. When I input java Move to the command line, it prints out the setup. So when I switch the bot.cfg file to point at ./Move (tried java ./Move) it should work for the first move right? It seems it just isn't finding it and I don't know why...

Title: Re: Case-based bot
Post by rbarreira on May 2nd, 2011, 2:50am

on 05/01/11 at 21:09:47, heroicjanitor wrote:
Hi I have another question, I am trying to use the bot interface kit with my class written in java. It takes the position file and returns the move, as per the instruction, but when I change the bot.cfg file to point at the java file it doesn't work... As an example(even thought it would only work for the first move) I tried to use a Move class with a main method that prints out the setup. When I input java Move to the command line, it prints out the setup. So when I switch the bot.cfg file to point at ./Move (tried java ./Move) it should work for the first move right? It seems it just isn't finding it and I don't know why...


Are you only printing the move? There are other things you need to print at startup, before you print the move. See the "Example Sessions" section in the aei protocol document:

http://arimaa.janzert.com/aei/aei-protocol.html

Title: Re: Case-based bot
Post by Janzert on May 2nd, 2011, 7:44am

on 05/02/11 at 02:50:43, rbarreira wrote:
Are you only printing the move? There are other things you need to print at startup, before you print the move. See the "Example Sessions" section in the aei protocol document:

http://arimaa.janzert.com/aei/aei-protocol.html


From a previous comment and the description above I'm pretty sure he is using the older "getmove" interface now. Unfortunately I don't have much experience with that interface or java to guess what the problem might be.

Janzert

Title: Re: Case-based bot
Post by rbarreira on May 2nd, 2011, 10:56am

on 05/02/11 at 07:44:55, Janzert wrote:
From a previous comment and the description above I'm pretty sure he is using the older "getmove" interface now. Unfortunately I don't have much experience with that interface or java to guess what the problem might be.

Janzert


Oops. I guess I mixed up two different threads here.

I don't know about the older interface either, my bot was using AEI from the start.



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