Friday, December 3, 2010

Programming competitions

After a nice long hiatus for my successful NaNoWriMo, I'm getting back into the game (ha ha)!

During all of the NaNoWriMo hubbub, one interesting piece of news that I had forgotten was that the Google AI challenge (www.ai-contest.com) was going on, ending November 27th. Unfortunately, I only remembered this on November 25th. I downloaded the C++ starter pack and tinkered around, submitting a pretty simple modification to the default bot that did an admirable job against the example bots included in the package.

Then I got to work on my own. I had some grand plans for my AI. First I was going to loop through the planets and calculate the available ships. For each planet I started with the current number of ships, then I looped through the enemy fleets to see if any targeted the planet. Then I calculated how many ships I would have by the time it reached me, subtracting the number of enemy ships. I kept a running total in case more than one fleet was enroute.

Unfortunately, I was behind on my word count and that was all I completed. I was then going to see if I could save the planets that I would otherwise lose. If I still had ships left, I would go for some neutral or enemy planets, starting with the largest that had the fewest ships (I already had a basic heuristic for calculating the best targets, which I would have tweaked).

Oh, well, there were some really cool entries, so I'm not sure how I would have done. Watch this funny battle in which neither side even attacks the other:

http://ai-contest.com/visualizer.php?game_id=9559045

It looks silly from our point of view, but you can tell what the bots are doing: they are protecting those two large planets from the other one. If either side went to grab another planet, they would have lost the big ones. The loser of that battle actually won the contest.

I had a great deal of fun tinkering with the bot and watching it compete, and I was sad that I didn't get to finish my own bot from scratch. However, I just checked out the latest Full Circle Magazine (for Ubuntu) and there is another AI contest going on right now! I haven't had the opportunity to tinker yet, but I did download the example and I hope to give it a shot!