Minimax with Alpha-Beta Pruning

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.

8 Replies to “Minimax with Alpha-Beta Pruning”

  1. 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

  2. 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 (,,

    Or did you mean more than that?

  3. 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

  4. 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.

  5. Joshua’s code is available from the Tic-Tac-Toe page at:

  6. 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 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.