27-Feb-2017

Tic Tac Toe

I have been wanting to write a Tic Tac Toe (TTT) program for a while but never found the right inspiration to actually proceed with an implementation. I've long since gotten tired of the standard and simple 3x3 TTT which does not offer much in the way of complexity in strategy and gameplay. But the fascination with programming a 3x3x3 TTT game finally got the better of me.

I remember reading an article in Scientific American, a long time ago, where matchboxes were used for the AI (Artificial Intelligence) to learn how to play 3x3 TTT. I also remember reading an article where an elegant and straight-forward algorithm was presented for the AI to play and win at 3x3x3 TTT. I have searched in the past and recently started my Internet search once again in hopes of finding a reference to that paper published article years ago.

Finally accepting that I will not find that article, I proceeded to devise my own algorithm. Here is a chronology of events.

  • On Friday, Feb 24, 2017, I started to think about the algorithm and spent more than half the day writing code for the mechanics of an AI autoplaying against an opponent.
  • I spent a good part of Saturday testing and fixing problems in my code. By end of day, I had good results where the AI was executing the strategy which I had devised was easily beating a naive player making random plays. Furthermore, I had begun the process of using 3D graphics programming to implement a User Interface (UI) for me to play against the AI for the ultimate in testing as well as to find a way to offer this as a smartphone app.
  • I spent half of Sunday doing the 3D graphics programming. And by midday on Monday, I had the prototype finished as can be seen in the following video.

As you can see from the video, the AI in red is far being an excellent player as I can handily beat it. There is work yet to refine the algorithm, including doing true machine learning for the AI to train itself for better winning performance.

After that, the hard part will come in getting this HTML and JavaScript implementation (currently runs in the browser) onto a smartphone (Android to begin with) where I face challenges in finding and implementing the 3D graphics needed for the UI. Furthermore, there will be design and appearance refinements for the app to make it appealing and for productization.

The first 90% of a software project takes 10% of the development time while the remaining 10% of the project takes 90% of the time to complete.

After this 3x3x3 TTT is perfected and made into a smartphone app for the Play Store, I shall tackle the 4x4x4 variant of Tic Tac Toe. Someday, I shall build a room size Tic Tac Toe construct!

View larger image

March 16th, 2017

Tic-Tac-Toe App has been completed and is available on Google Play

Android app on Google Play


Blog Entries Listing
2010  Aug  Sep  Oct  Nov  Dec 
2011  Jan  Feb  Mar  Apr  Jun  Sep  Oct  Dec 
2012  Jan  Feb  Apr  May  Jun  Oct  Nov  Dec 
2013  Jan  Feb  Mar  May  Jun  Dec 
2014  Jan  Mar  Jun  Jul  Aug  Oct  Nov  Dec 
2015  Jan  Feb  Mar  Apr  May  Jun  Oct  Nov  Dec 
2016  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec 
2017  Jan  Feb  Apr 



YafaRay Stoneage



Intellectual property has the shelf life of a banana. - Bill Gates

Share / Save
Provide Feedback

Share / Save    Provide Feedback