Tic-tac-toe

Final Project
CSPP 50101
Summer 2005


Tic-tac-toe, a game of X's and O's...

Your task is to design and implement a tic-tac-toe demonstration, where the humans watch computer players going head to head. We will sit back and watch the computer players make move after move, waiting to see which side wins, or if it all ends in a draw.


You will turn in two items: the design of your system, worth 40% of the project grade; and the full implementation of your design, worth 60% of the project grade.

Note: A design will be provided as an alternative to using your own design; by using this design instead of your own, you will be forfeiting the ability to earn an A on the project.

After you have submitted your design, you must meet with me (or discuss by phone if necessary) to discuss your next step.

Design is due: 5:30pm Sept 1. Meeting before: Saturday Sept 3. Final due date: 11:59pm Sept 9th



Design


A traditional tic-tac-toe game consists of a 3x3 grid with nine spaces and two players, each in control of one piece. The players take turns placing either an X or an O on the board. A player wins when they have placed three pieces in a row, either horizontally, vertically, or diagonally. If there are no more spaces to play, and no one has won, the game is a draw.

In our computer version, a game consists of a board, pieces, players, and an arbiter to ensure that the game is played properly.

Develop a design that will represent your tic-tac-toe program. Present the design using diagrams and any additional text you feel necessary to explain your intent. Note: this will be a physical document you hand in.

This design must include:

A board : 30 points
A player : 20 points
A piece (i.e. X & O) : 20 points
An arbiter : 30 points


Implementation

To implement your tic-tac-toe program, you must implement your design, incorporating whatever modifications we discuss. (Or the design you will be given).  However, you do not have to fully implement any extra credit portions of the design. (For example, while your design may support more than two pieces, your implementation does not have to provide more than X and O)

This project should be written in the full Java language, using the JDK. This is available on the lab computers.
A file is compiled by entering 'javac File.java' and then run 'java File'. Note File.java must contain a method named 'public static void main( String[] args )' to run. All classes of your program should be in a package: jsmith_tictactoe, where jsmith should be replaced with your first initial and last name.

You may use the ProfessorJ advanced language instead if you choose to do the graphics extra credit option.

When run, the arbiter of the game should begin the game and request a move from the first player. The arbiter should then cause the board to be presented to the outside world, and ask the second player for a move. This behavior should continue until the game has ended, at which time the arbiter should present the winner to the outside world.

If your program supports arbitrary size boards and/or more than two players, this information must be gathered by the arbiter before beginning the game.

Overall point breakdown:
Program compiles (and is actually a program, no credit will be given for compiling mostly empty files): 25 points
Program runs, with a complete game : 40 points
Program is properly documented : 20 points
Other criteria is met : 15 points

Proper documentation :
This includes the purpose and examples for your methods. Methods that directly return the value of a field do not need examples. This additionally includes a document (called README) that explains how your program is used.

Other criteria :
Your program must contain a player that can block an obvious win of the opposing side : 10 points
Your program detects diagonal wins (except in scenario described below) : 5 points

Extra credit:
Support for NxN board : 5 points (note, you do not have to support diagonal wins: horizontal or vertical wins must be all the way across, but you will receive 2 additional points for doing so)
Support for more than 2 players : 5 points
A player that can choose it's play based on a strategy : 15 points
Instead of using the information below to display the game, use ProfessorJ: Advanced and the drawing library to present a graphical demonstration of the game in action. You must additionally implement a small program using full Java, for practice: 20 points

Information regarding displaying the game:

Java provides the ability to display information to the user of a program: System.out.println( ... ).
This method accepts a String, and displays the string on one line of output. For example the following lines would produce an acceptable tic-tac-toe board:
System.out.println( "X | O | X");
System.out.println( "O | X | O");
System.out.println( "O | X | O");

Information to do graphical extra credit: drawing library page

Submission:

You should submit your program electronically (i.e. e-mail it to me). Since your program will be a directory instead of a single file, please use either tar or zip to combine your directory into one file for submission.  Within this directory, your main program file must be TicTacToeDemo.java



FAQ

  1. Q. When will you add questions to the FAQ?
    A. Pretty much when I get them
  2. Q. When the board is 4x4, 5x5, etc, would the player have to get 4, or 5 in a row, or still three?
    A. The player must get N in a row, where N is the size of the board, so 4 on a 4x4, 5 on a 5x5 etc
  3. Q. How do I accept moves from the human player?
    A. This is beyond the scope of the project. There are no human players in this tic-tac-toe demo. Your program will instantiate two computer opponents, who will compete against each other.
  4. Q. How do I get a random number?
    A. There is a class that generates random numbers. This is java.util.Random. Import and create an instance of this class, with no arguments. To get a random number use the method 'int nextInt( int n )' This method will return a random number between 0 and n
  5. Q. Can I modify my design as I implement?
    A. Minor modifications are to be expected. You may make minor modifications, but please document these in your README file before you turn in your program. (Minor modifications include the addition of helper methods, some changes in arguments, but not changing the overall communication strategy between different parts of your program). If you are contemplating a major change to your design, please communicate with me on an individual basis.


FiFo Queue.
I am providing the following archive of an implementation of a fifo queue, for anyone who wishes to use it.
To use it, download the file, unpack the archive, and put the resulting directory in your project directory. To use the queue, put the following line in whichever Java file you wish to access the library from: import support.FiFoQueue;
FiFoQueue