Project 2 - Tic Tac Toe Winner
Part 1 - Due - November 15, 2004
Part 2 - Due - November 29/30, 2004
In this project, you will write a program which determines the winner
in a game of tic tac toe. Tic tac toe is played on a 3x3 board. The
game must have exactly two players. Player 1 is assigned the symbol
'x' and player 2 is assigned the symbol 'o'. Players take turns
placing their symbol in one of the 9 possible squares on the board
until all squares are full or until one of the players has three of
her symbol in a row (across, down, or diagonally). You can play a
version of the game here: http://www.prongo.com/tictac/.
Your job is to write a program which will read in a board
configuration from a file and determine (1) if the board configuration
is valid and (2) which player (x or y) has won the game. A board is
valid if (1) the difference between the total number of x's and the
total number of o's is less than or equal to 1 and (2) 1 or 0 of the
players can be declared a winner. The contents of the file will look
like the following:
o--
xox
x-o
A '-' symbol inidcates that no player has placed their symbol in that
slot of the board. In the above example, your program would determine
(and print for the user) that the board is valid and that player 'o'
has won the game.
Notice, your job is not to implement a program which will allow a user
to play the game. Your program only needs to read a board in from a
file, determine if the board is valid, determine who won, and print
the results. If you wish to write the code for game play, you can
speak with me about doing this for extra credit. You must make an
appointment to speak with me, in person, if you wish to take advantage
of this extra credit opportunity.
Implementation Hints
Work on one piece at a time. First, write the algorithm for the
function(s) which read the contents of the file and store the board in
memory. Then, write the algorithms for the function(s) which
determine the winner for a given board. Next, write the algorithms
for the function(s) which determine if the board is valid. Finally,
put it all together and write your main algorithm. Once you have
completed the algorith, write your code in the same order. Debug it
and test it one piece at a time.
Part 1 - Due Monday, November 15, 2004 - 8:35AM
Submit a program design and series of test cases.
Part 2 - Due - November 29/30, 2004 - Beginning of Lab
Submit your completed code.
- Make sure that each function is well documented. Your documentation should specify the type and role of the input paramaters and ouput.
- Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.
Sami Rollins