Well, I’ve been able to churn out my first game and it’s just TicTacToe. It has been more difficult than I would like to admit. But I’m really happy with the way it turned out. Here’s the download link for the jar and before you download it, please note that you cannot win against the computer :).
http://s17.postimage.org/sgtogzht7/tictac.jpg
Here’s some details about the game. I recently learnt Scala and wanted to implement the AI completely in Scala. For this I first created a simple text based game in Java with the move recommender engine in Scala. Once the text game worked fine, I used Slick to create the game and Inkscape to create the (lame) graphics.
There is a standard strategy for TicTacToe as given on Wikipedia. But I wanted to come up with my own strategy for it. So I didn’t bother to look at this link until far later when my AI wasn’t performing optimally.
I’ve developed a recursive score based AI which calculates all possible moves and assigns a score to every possible move. But this method led me to 3 issues - viz incorrect handling of
- forks
- immediate wins
- immediate losses
So, I’ve had to adapt a bit of the standard strategy to fix these issues. Forks were handled through hardcoding.
In any case, I’ve cut corners everywhere in this project. The code is an unmaintainable mess with hardcoded strings, numbers and pixel locations. But there are far better tictactoe implementations out there, so I didn’t want to make too much of it. It’s more or less a Proof of Concept.
I’m happy to have been able to integrate Java, Slick and Scala.
Btw, creating the jar has been a nightmare. Thanks to jarsplice, I was finally able to make it. The complete instructions on how I did it are here: http://stackoverflow.com/questions/13527869/could-not-find-main-method-from-given-launch-configuration-when-using-javasca