Update: Sinatra Tic Tac Toe

Task: Play human-human tic tac toe in a browser. Stories include:

- place marker into a square
- marker switches for opponent
- when game is over, display a GAME OVER message

After grappling with Sinatra and the swath of material I have had to rapidly assimilate, I think I have finally made some real progress on this latest story. As an example, I will walk you through what my Sinatra-hosted tic tac toe game can do!

After starting things off with a ‘ruby config.ru’ command, Sinatra starts out running my sinatra_ttt.rb file (a.k.a. a route file, because it contains all the html routes for the app). This takes us to the home page at localhost:4567.

Image

After clicking on the link the user is taken to the configuration page filled with options. There are six radio buttons, each with a pre-selected option so that there are no nil/null errors.

Image

At this point the configuration does not do anything other than create some cookies that can be used later. So we click ‘Submit’ with the default configuration and are taken to a blank tic tac toe board:

Image

I start out by selecting the middle square:

Sinatra_Move_1

And then select the top left square. Notice that the marker changes without having to do anything.

Image

Just to show that the marker switches back automatically, a third move:

Image

On the docket for tomorrow is to ensure that when a marker is placed on the board that it cannot be changed, and that a GAME OVER message is displayed when all of the squares are filled.

The code for this project can be found here:
https://github.com/pszals/sinatra_ttt