I wrote this application as a Rails 3 app and deployed it to Heroku at this url: http://hollow-flower-49.heroku.com/.
It uses a single controller ('game') with no models or database storage.
The application was tested in Firefox and Google Chrome. Other browsers should work but haven't been tested.
The layout of the tic tac toe grid is a simple HTML table with CSS sized elements. X's and O's are applied to squares by a javascript onclick function and the application of a CSS background property with my two hand-drawn images shown below.
![]() |
![]() |
Logic and strategy for computer play was extracted from this Tic Tac Toe Strategy Guide. Source code comments describe how the logic was extrapolated and implemented.
The majority of programming for the game was done in tictactoe.js.
To see the core logic code, see computer_make_move in tictactoe.js.
Other files that I coded for this app are:
This application is released under the GPL. To download the complete source code to this Rails application, click here.
Peter Giacomo Lombardo
http://www.peterlombardo.com
November 1, 2010