Sunday, February 20, 2011

Planet Wars - My First AI Contest (part 1)

I can't believe I wasted 2 months on this. I can't believe I comprehensively wasted 2 moths on this at all! (those who have red the blog of the winner, Bocsimacko The Brilliant, will find that phrase little familiar :-) )

It was late when I got to know about Google's AI contest. I have missed the first contest as well, I got to know about the second contest, "Planet Wars" just few days before it ended. Considering the competition was running for over 2 months, that didn't give me much chance to compete effectively. To make the matters even worse, I was to find out (foolishness of me, should have checked that out before everything else!) about the submission deadline just a day before it!

So I ended ended up hurriedly submitting not even the best code I have written in those few days. And the competition was of course a disaster for my Bot. May be I should have satisfied with the results (1200 out of 6000 competitors) of what was made in just 4 days, but something else happened during the final competition.....

I really began to get carried away by the beauty of the game, and the challenge it offered. I just continued development of my bot hoping that the competition server will keep running even after the official competition so that I could still evaluate my bot by playing it against others. Unfortunately, official server was never started after the actual competition. Can't blame the organizers for that. They have provided a wonderful experience and organized a hugely successful competition. What's more, they have made the server software open source. Few people were already running their own TCP servers where others could compete. However, after the competition, even the players seemed they are tired after a competition which ran for over 2 months, and no one was so keen on playing on TCP servers. Even the servers were not available after few days. At least all my attempts to connect to one was ended in failure.

My only remaining option was to download the bots published by others after the competition and play my bot against them in locally arranged tournaments. By this time my bot was improving fast and I was in a hurry to implement all my ideas and see how they would fair up against other bots. So I didn't look into downloaded code as that would influence my thoughts and I wouldn't be able to test my bot in a fair manner. A big big thank for those who published their code. I downloaded the java bots I came across, so my special thanks goes to GreenTea(ZerlingRush), Smloh, Manwe56, Deccan, Exaide, Eburnette, Ludakris, zvold(krokokrusa), InvaderZim. Without you guys it won't be possible for me to test my bot at all and you helped me to improve myself a lot. Looking forward to compete with you in a real tournament soon.

GreenTea was always a tough opponent for my bot, so was Smloh1. At initial stages almost all bots were very difficult to beat. I implemented features one after other, attack first, defense, neutral planet hunting etc and things improved dramatically. specially after proper defense and optimized neutral hunting. As for attacking, less attacking the better it was top bots were very quick to punish incorrect attacks. I thought Ludakris was a better bot than it's rating suggested, specially in close quarter battles. Manwe56 was little slower than other bots for some reason but was stronger than my one in most cases. Exaide has a random behavior as it was getting different results against the same bot on same map! it was a mysterious bot for me in the beginning. I felt I was bit luckier against Mkemp, zvold and eburnette and may be bit unlucky against Deccan whom I couldn't reach on ratings even though individual matches against that bot went close. Smloh1 was slow initially until I had to investigate and eliminate system.outs from the code :-)

It took about 2 months before this craziness ended and I had enough improving my very first AI bot. If the competitions I locally arranged is to be trusted and ELO tables do a good job in measuring performances and translating them into ratings, then I think I could be somewhat satisfied with my efforts. My final bot performed around 3280, (it got very close ratings in 2 different sets of maps against same opponents, so I guess the performance rating calculation is fairly accurate) which would mean had it managed to compete in the real competition, it may (arguably) have ranked somewhere between 60 - 70. I may have got an advantage since I have few good bots at hand to test my bot against with, but then again in the real tournament preparation, competitors may have had the privilege of playing against others on TCP servers as well as in the live server.

I didn't do fine tunings targeting the final tournament maps since my interest in the game dried down after solving the challenge of implementing all my game strategies and getting them to work. Some fine tuning would have helped to snatch up few more rating points... but my main interest was to get the algorithms right.

Now that the initial goal is achieved (to build a decent bot on my own), I can now go visit others code and analysis, learn something new and have a laugh at clumsier ways I may have achieved certain things in my code.

Source code of the final bot can be found in here. Excel with all tournament statistics and rating calculations along with ELO tables used is also there. I'm planning to explain my code, strategies and lessons learned in a future article if the time permits. Meanwhile, apologies if the code lacks enough comments.

All the best for all contestants in the upcoming contest! those who haven't get involved in this fun, do sign up!! trust me, you won't be regretting this. (specially if you like AI programming and/or problem solving in general)

Part 2

No comments:

Post a Comment