I originally planned for this to be a massive 9 part tutorial on building a game with an AI. Despite my “I will finish this even if it kills me” attitude, I finally changed my mind, deciding to cut to the chase and just post the end result. This came from the realization that even if I did finish writing the last third of the tutorial, it would still be boring and dense and honestly not something I was excited about. I was mistaking stubbornness for perseverance.

Don’t get me wrong, I’m not getting all emo here. I still have a working game AI that I’m proud of, and I’m still going to share it. Here’s a screenshot.

game AI screenshot

And without further ado, here’s the actual finished board game AI.

DemoBoard Game AI

The presentation is all HTML5 Canvas. The AI uses a minimax algorithm to pick its moves. Feel free to view the JavaScript for all the source code. It’s pretty well commented, but if you have any questions, feel free to ask. After all, this was originally meant to be something people could learn from.

I call it “finished”, but code never is. The UI could be snazzier and the AI could use a few improvements. Maybe I’ll come back to it one day, but for right now, I’m ready for something else.

Update: Guess what? I came back to it. Read my Align 4 retrospective to find out about the updated version.