Due: 4 Nov 2005
Educational objectives:
Statement of work: (i) Implement generic stack and queue classes, and (ii) use your stack class to play the game NIM, as described below.
Deliverables:
(1, 2, 1)
. (We will discuss game trees in recitation and in class 11 Oct 2005.) Each individual (rather than each group) must turn in a solution, for this task alone.
makefile
and
all header (*.h) and cpp (*.cpp) files that are needed to build your
software, as described in www.cs.fsu.edu/~asriniva/courses/DS05/HWinstructions.html. Turn in your development log too, which should be a plain ASCII text file called LOG.txt
in your project directory. You will submit all of these using the project4submit.sh
script.
Background: This game involves two players, and starts with a certain number of heaps of objects (say sticks), with each heap containing a certain number of sticks (the number may vary from heap to heap). The players alternate in taking turns. In each turn, a player has to remove objects from exactly one heap. The player may remove any number of sticks from that heap, but must remove at least one. The game ends when there are no more sticks left in any of the heaps. The last player to remove a stick loses.
Requirements:
proj4
.makefile
in this directory. In addition, all the
header and cpp files needed to build your software must be present here, as well as the LOG.txt
file.stack
class with at least the following features: (i) void push(T &)
, (ii) void pop()
, (iii) T &top()
, and (iv) bool empty()
.
queue
class with at least the following features: (i) void push(T &)
, (ii) void pop()
, (iii) T &front()
, and (iv) bool empty()
.
./nim <c/h> <m> <N1> < N2> ... <Nk>
will cause a NIM game to be played with k
heaps, having initial number of sticks = <N1>, <N2>, ..., <Nk>
respectively. The argument c
makes the computer play first, while the argument h
lets the human play first. The argument m
specifies the number of moves in the future that should be evaluated using the game tree. Nodes beyond that level should be evaluated using any criterion that you wish to use. For nodes within the level specified by m
, you must use the mini-max procedure described in class. However, you may use pruning strategies and symmetries to reduce the number of nodes evaluated, if you wish to.
Sample executable: A sample executable is available at ~cop4530/fall05/bin/nim
on linprog
. The first person to find errors in our program will get a bonus point!
Bonus points:
You may get up to 10 additional points for providing a good GUI interface. You may also get 10 additional points if your implementation plays as well as ours!
Notes:
list
, vector
, deque
, stack
, or queue
classes. You may use the string
class. Please get my
permission before using any other STL feature.
stack
and queue
classes on entirely different applications. So it is
important for these classes to be generic and exactly as specified.