CSCE 4013 - Homework 1
Due Date - 01/30/2014 at 11:59 PM

1. Problem Statement:

The purpose of this programming assignment is to implement one of the earliest mainframe computer games, three-dimensional tic-tac-toe played on a 4x4x4 board between the user and the computer. The user and the computer take turns placing X's and O's on the board, and the first one to get four in a row wins the game. The game also ends if all 64 board positions are filled or if it is impossible for either to win.

This project will give you experience with three basic game programming concepts: 1) getting user input, 2) displaying the game board after every move, and 3) creating a computer opponent to play against the user. To keep things simple (and authentic) this will be implemented as a terminal-based game where the user will type in commands at the keyboard, and the game board will be printed on the screen. For example, if a user types in coordinates 2 3 4, their X will be placed on level 2, row 3, column 4 as shown in the board below.

+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
|   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
|   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
|   |   |   |   |   |   |   |   | X |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
|   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
     level 1             level 2             level 3             level 4

To simplify user input, assume that the user enters three integer values when prompted. If these values are all within 1..4 and the board location is empty, you should save their X at that location. If the coordinates are invalid, or the position is already taken, you should prompt the user to try again.

2. Design:

One of the reasons the 4x4x4 game is so much harder to play and win than the 3x3 tic-tac-toe is because there are 152 possible ways to get four X's or O's in a row (7 starting at each corner point "c", 3 starting at each side point "s", and 1 starting at each middle point "m" in the diagram below). You will need to design several loops over the levels,rows,columns in the board to count the number of X's and O's and see if someone has four in a row.

+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
| c | s | s | c |   | s | m | m | s |   | s | m | m | s |   | c | s | s | c |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
| s | m | m | s |   | m |   |   | m |   | m |   |   | m |   | s | m | m | s |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
| s | m | m | s |   | m |   |   | m |   | m |   |   | m |   | s | m | m | s |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
| c | s | s | c |   | s | m | m | s |   | s | m | m | s |   | c | s | s | c |
+---+---+---+---+   +---+---+---+---+   +---+---+---+---+   +---+---+---+---+   
     level 1             level 2             level 3             level 4

Designing an "optimal" computer player for 3D tic-tac-toe is way beyond the scope of this project. We are not trying to compete with IBM's Deep Blue chess playing supercomputer. Instead, you will be asked to implement three levels of game play:

Your final program should prompt the user for the difficulty level of the game (c = chimp mode, k = kindergarten mode, and p = professor mode) and then use the corresponding mode above.

3. Implementation:

You can implement this program using either a bottom-up approach or a top-down approach. If you go for a bottom-up approach, start by creating basic methods and classes, and test theses methods using a simple main program that calls each method. When this is working, you can create the main program that uses these methods to solve the problem above.

If you go for a top-down approach, start by creating your main program that reads user input, and calls empty methods to pretend to solve the problem. Then add in the code for these methods one at a time. This way, you will get an idea of how the whole program will work before you dive into the details of implementing each method and class.

Regardless of which technique you choose to use, you should always develop your code incrementally adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete. Also, remember to keep backup versions of your code, so you always have a version to fall back on if you accidentally delete your code or your changes do not work out.

4. Testing:

Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. You are required to include your testing results in your project report to demonstrate that your program works correctly. To do this use the "script" command to save all program input/output in a "typescript" file, and cut and paste from this ascii file into your program documentation.

5. Documentation:

When you have completed your C++ program, use the "Programming Report Template" on the class website to document your programming project. This report has separate sections to describe the problem statement, your design decisions, your implementation process, and your testing results. Each of these sections should be 1-2 paragraphs long, so your completed report will be 2-3 pages long once you have included your testing output.

6. Project Submission:

In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "Upload" your documentation (a single docx file), and your C++ program (a single ascii text file).

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.