CSE 111 - Fall 2002
Lab #10 - Tic Tac Toe
Background
For this lab, you will build the game of tic tac toe. You will play against a very unsophisticated computer player. The game of tic tac toe consists of a board 3 x 3 squares. You the user are the X and the computer is the O. You will click on a square to make the X appear. After you place your X, the computer will check to see if you have won. If not, it will place an O randomly on the screen. Again, the computer will check to see if there is a winner. If either player wins the game, a message will be displayed stating who won the game. Play continues until a winner is reached or there can be no more X's and O's placed on the screen. At that time, a draw is called.
For your implementation, you should find an image for the X and for the O. Note that this does not have to be X's and O's specifically, just two different images that represent you and the computer. You should have a variable that stores these images so that you can compare things in the future for them.
One strategy for getting the computer player to place it's O's is to pick a starting square at random at the beginning of the game, and put squares in every square after that for its move.
Extra Credit
For additional credit, you can implement your Tic Tac Toe game so the computer will be "smart". That is, the computer will look for a square that will give them the win, as opposed to just any random square. You may also implement a "Best of Three" tournament you against the computer.
Sample Interaction
Below is a possible sample interaction with the Tic Tac Toe game to be used as a reference.


