COP4530 Fall 2004: Assignment 4
Due: 1 Nov 2004
Educational objectives:
Statement of work: (i) Implement a generic deque class, (ii) implement stack and queue
classes, using your deque class, and (iii) use the stack to develop a program
that will play tic-tac-toe, as
described below.
Deliverables:
-
15 Oct 2004, 4 pm: Email me the names of people in your group by this
deadline. A group may contain three or four people. If you want me to assign
you to a group, then please let me know.
-
19 Oct 2004, 5 pm: Give me a hardcopy of a simple design document,
which describes different classes that you will implement, the basic idea
behind your algorithm for playing tic-tac-toe (you need not specify the strategy
for evaluating a position), specify the person responsible for implementing
each feature, and mention the time that you expect to take for implementing
each feature.
-
26 Oct 2004, 5 pm: Give me a hardcopy of a progress report that
describes the different features that you have implemented.
-
1 Nov 2004: Turn in a makefile, LOG.txt
file, and all header and cpp files that are needed to build your project, by 1
Nov 2004, as
described in www.cs.fsu.edu/~asriniva/courses/DS04/HWinstructions.html.
-
Group
demonstration of your project: TBA.
Background: We discussed the game of tic-tac-toe in class, with a 3x3 array. This can be generalized to bigger arrays. All cells in the array are initially unmarked. Players take turns marking previously unmarked cells, with the first player making an X mark and the second player making a 0 mark. The game ends if (i) either player wins, or (ii) the game is tied, because neither player wins. A player wins if he has a specified number of consecutive marks along a line. These consecutive marks can either be along a horizontal line, a vertical line, or a diagonal. A diagonal is as explained below. Let the cells be numbered so that the bottom left cell is denoted by (1,1) and the top right by (n,n) in an n x n array. A diagonal going North-West will have cell (i+1,j+1) adjacent to cell (i,j), while a cell going North-East will has cell (i-1,j+1) adjacent to cell (i,j). http://boulter.com/ttt/ has an example of a tic-tac-toe game. They permit an array that has a height different from its width. But we will require the height and the width to be equal. Note that their program is easy to beat.
Requirements:
-
deque.h: This file implements a simple generic deque class
with sufficient features to implement a stack and queue class as described
below.
-
stack.h: This uses the deque implemented above to implement a
generic stack with at least the following features: (i) void push(T &),
(ii) void pop(), (iii) T &top(), and (iv) bool empty().
-
queue.h: This uses the deque implemented above to implement a
generic queue with at least the following features: (i) void push(T &), (ii) void pop(), (iii) T &front(),
and (iv) bool empty().
-
Other files: You may use more files.
-
main.cpp: This is the main program. It will accept two command
line arguments. The command: ./proj4 <n> <m> <h/c>
will cause a tic-tac-toe game to be played using an n x n array, with m marks in a line needed to win. The argument h will cause the human to play first, while a c will cause the computer to play first. For example, ./proj4
4 3 h will play a tic-tac-toe game on
a 4x4 array, with 3 consecutive marks required to win, and the human
playing first. Whenever it is the human's turn to play, the program should
present the current state of the game, and specify how the human should let the
computer know about his/her move. The human has unlimited time to make a move.
However, the computer should complete its move within 5 seconds. The program should also give the correct
final result of the game.
-
makefile
Notes:
1. Extra points: You can get up to 10 bonus points if you
create an X-windows or web-based GUI. You can get up to 10 bonus points if your
program wins a tournament we will organize.
2. You should not use the STL deque, or stack, or vector classes.
3. You will be grade on your user interface too.