through countless years, a lazy life series

Tuesday, September 9, 2008

Amazons AI Competition - GeeX

My friends at GeeX started an AI programming competition, So If any of you guys are interested hope you'll join us, here it goes:

Yo.

I was talking to our good friend Suhib Al-Sisan the other day, when one idea to another, we conceived an idea for a new programming competition.

*Intro*

Amazons <http://en.wikipedia.org/wiki/Game_of_the_Amazons> is a board game, it is mainly a territory game. *It is really fun!* The rules are simple, yet you will be amazed to find the game requires some good thinking. It is not as hard as chess, but not as easy as 4-to-win (or whatever it is called). It's perfect when you don't want to get bored playing, yet you don't want to
exhaust yourself thinking.

I have programmed many version of it, we (that is, me, Waleed and Mohamad Qasem) actually did a physical version of the game as a project in one course! Some of those verison were multiplayer over the internet, this helped me (and I think the other players) realize how fun it is.

*The Competition*

I once tried to write an AI to play it, and it wasn't bad for my first time. This came up while chatting with Suhib, and *the new competition's idea is as follows*: Each participatant writes an AI, in his prefered language (more to come about this), then the AIs are run against each other, probably in a tournament style to find the best AI.

To accomplish this,* I started by writing "the Central Unit". The Central Unit allows you to* run your algorithm, and play against it, or make multiple algorithms play against each other while you watch their moves (or you don't, and just see the results).

The first version of the Central Unit is attached in this email (v0.5? Seems reasonable for now). It took around 6 hours of work, the graphics are taken from Wikipedia (I plan to use my own graphics, but I don't have them on my laptop for now), and I am providing it under GPL, or whatever *:P*. Expect the code to be very ugly, but working. I'll be cleaning stuff up if I find
you guys are interested.

*Central Unit (CU) Manual*

So, CU comes in a ZIP, extract and run "main.py". Under Linux this would be "sudo python main.py". You need the sudo part because the script hooks up to port 80. You access everything from your browser, opening "localhost". I did it that way to make it cross-platform, without much overhead in coding or installing.

The game has two players as you should know by now, white and black. Either of the players can be a human or a script at any point in the game (you can switch back and forth as much as you want).

Now, regarding programming language, your program has to be runnable from a terminal, and ends its process by itself. Before the program is ran, a file named "amazons.in" will be generated in the folder containing "main.py". *This file will contain the information about the current board, and the list of all moves as follows*:

- First 10 lines each contain 10 characters. Each line represents one row of the board. Those characters are ASCII characters representing numbers in the set {0, 1, 2, 3}. A "0" represents an empty square, a "1" represents a marked square, a "2" represents a white queen, and a "3" represents a black queen. The first character represents the sqaure a1, the last character of
the first line represents j1.
- This is followed by a line containing a value *N*, representing the number of moves played so far.
- This is followed by *N* lines, each representing a single move, expressed as a string of the form xn-xn/xn, where "x" is a letter from "a" to "j", and "n" is a number from 1 to 10. The first part represents where the queen was moved from, the second where it moved to, and the last where an arrow was thrown. Those lines each always matches the regular expression:"^([a-j])([1-9]|10)-([a-j])([1-9]|10)/([a-j])([1-9]|10)$".
- Lines are seperated by a carriage return and a line feed ("\r\n").

Your process should read this file, and write another file "amazons.out" in the same folder, *containing the move it decided to* *do* in a format similar to the move described above. An optional empty line afterwards is accepted.

*Your process HAS TO THEN END*. The CU won't kill your process and will not return until your process ends. If you are writing your code in MATLAB syntax, I recommend you use octave instead of MATLAB, it starts kind of faster and it ends really nicely.

When playing as a human, click the square from which you would like to move your queen, followed by the destination, followed by the place of the arrow.

*Things You Should Know*

- The code is not yet finished. I am providing it early to see how many of you are interested, and allow you to start working on your AIs early on.
- Some features aren't yet implemented, in particular, the CU doesn't know when a game is over. This also means the "Fast Forward" and "Forward to End" aren't implemented yet.
- I know you can click on squares that don't make sense, nor follow the rules when are you playing as a human. This is because the CU deals with a human player just like a script player, it only evaluates the move when asked to (when you click next "Step Forward" for script or when you choose the place of your arrow for human). I might fix that later on.
- So far none of us has written an AI for it, so you can either start playing it human-vs-human, or implement your own AI. I think I will be doing one soon.

Feel free to reply if you have any questions.

I am looking forward to hearing your comments and suggestions (and excitement about the idea? *:P*).
-- Sinan

You can download the CU code here
Sinan's vandal code (un-intelligent version) here
Suhaib's shabah code (Linux here, windows here)
Omar's omko2 code here.

Try them out guys, see which code wins ;)

4 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home