Sunday, January 20, 2008

Dots AI

A bit of time spent on Ultimate Retro Project. I reworked the classic dots input system so instead of having to deal with three separate prompts, you only have to input a single command in the format DCR. D is the direction which is either the letter H or the letter V. C is the column, which is a number. The rows have become letters so the final part is a letter. Parsing this is fairly easy, as you just take the character in position 0 of the string and make sure it is H or V. You then take the middle characters and convert them to an integer. Finally, the last character is converted to uppercase ASCII and has 65 removed from it (the ASCII value for A) to give you the zero based coordinate.

I also wrote a fairly simple AI class. This was quickly written just to get some type of computer opponent into the game. I had initially intended to later write a recursive AI for the game, but after playing with the AI I think with only a tiny bit of work I could actually salvage a reasonable game out of the simple AI. Right now the AI essentially places a line randomly on the board. It is, however, smart enough to notice when there is a box that can be completed and will automatically complete that box.

My next step is going to be cleaning up the classic version and getting it working with multiple board sizes. The modern version uses the same game core and AI classes as the classic version so once I have the classic version finished, the modern version will follow shortly after. While I am not going to make any promises, I hope to have both the classic and modern versions of dots ready for February.

No comments: