When trying to understand minimax with alpha-beta pruning I found loads of Computer Science-type material on the web. But very little in the way of practical examples.
Hopefully my java Tic-Tac-Toe game with perfect AI that uses this technique will be useful to someone looking for a practical example.
If you have any questions, please put them in the comments here and I’ll do my best to answer them.
I found your example helpfull and i was able to create my own but you have a lot of run around code. After i get done fine tuning mine. Would you like to have a look at it and post that as another example on your site. I only use 3 classes a Board, AI, and Node. its done in swing. I might also include depth limiting
I only decided it was a Minimax a-b example after I’d written it! So yes, there’s the ability to plug in other types of players and other stuff that is unnecessary in that respect (Boring.java, Human.java, Player.java).
Or did you mean more than that?
No. I ment if i was just starting to look at code and i wanted to simply plug and play your AI into mine i would have to figure out how you make your board and how you pass variables from class to class. I took a lot of your code and just made it human vs ai and into a Swing UI so when you look at the code you can easily follow what the AI needs and what is just setup. I also increased the effancy a little bit on my machine it went from 80mb ram to 60mb ran used and 2.5s to generate first move to 1.5s Ill email you my code later today or tomorrow
Yeah, true, it is a bit over-complex as an example. But at least it is real working code as opposed to pseudo-pascal like most alpha-beta pruning examples are written in. I look forward to seeing your version.
Joshua’s code is available from the Tic-Tac-Toe page at: http://bluebones.net/tictactoe/
I cant find the source code for the TIC TAC TOE with AI. The source is removed.. :S
where to download the source code?? links are giving 404 error!
Sorry guset, all this stuff was lost in the great server crash of 2009. One day I will search my old backup CDs and find a copy and restore it but not this week 🙁