Homework 4
CS202, Summer 2006

Due: Tuesday, August 15

Please upload your source code files using CSNS. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.


[Problem Description] Tic Tac Toe is a game played on a 3 by 3 grid by two players, Player 1 and Player 2. Player 1 starts by placing a circle (which can be represented by the letter O) at an unoccupied grid position. Then Player 2 places a cross (which can be represented by a letter X) at an unoccupied grid position. Play alternates between Player 1 and 2 until one player's symbols occupy an entire line (vertical, horizontal, or diagonal), in which case that player wins; or the grid is filled, in which case the game is tied.

For this assignment you are going to implement the Tic Tac Toe game with a Java GUI application. In particular, your GUI should include at least the following components:

Note that your GUI interface should automatically adjust to the size of the window. For example, when the window is resized, the board should be enlarged or shrinked accordingly.

[AI Player] For extra credit, add another game mode where a human player can play with an AI player. The AI player follows a simple strategy:

[Grading] The total points for this project is 100, with 40 extra credit if you choose to implement an AI player.