Tic-Tac-Toe

Problem Statement

During the summer between 3rd grade and 4th grade my parents sent me to "baseball camp."

This was because despite playing baseball for three years at that point I had only hit the ball twice1. I was often put in the left outfield position where I would pick dandelions. Being literally "left out" made me sad but the whole display made my father proud.

Instead of applying myself and learning how to play baseball I had a notebook where I wrote out all the different games of tic-tac-toe determined to "crack the code" and never lose again. I thought I was being so smart and, in my defense, so did the other children. A loser, yes - but smart.

Even today when I go to dinner with my siblings or parents we ask for the kids' menu and crayons over 50% of the time. We then play at least one game of tic-tac-toe at the table of a nice Italian restaurant2.

Your Goal

Make a program that lets you play tic-tac-toe against the computer.

Make sure that the player is not allowed to make invalid moves, that the computer does not make invalid moves, and that the game will not crash on unexpected input from the player.

Future Goals

When you learn enough to do the following, come back to this project and expand it.

  • Implement a few different options for the AI including "pick a valid move at random".
  • Allow for setting up simulated matches between the different AIs
  • Expand the game to have the option to play "ultimate tic-tac-toe."3
  • Make the program have a graphical interface and let people click to make a move.
  • Allow for playing with other players over the internet.
1

Tee Ball excluded.

2

I am not Italian.

3

Ultimate tic-tac-toe is actually a much better game.