In order to ensure that each group designs their tree class based only on the interface specified in the description below, to get the game and state classes from me to test your code, you will have to submit your code to me first. This code will not be graded or tested. Have one person in each group submit the code, and send me email when you do.
(10/30: note change in blue)
With your group, design and implement a game-tree template class that plays a game against a human user. The template should take as an argument a game-state class which is specific for a particular game. You will test it with a .o file I will provide. You may rely on the game-state class having at minimum the following interface (10/27,10/29- note the changes in blue):
list<gameState> nextMoves(); // returns a list of states representing the possible next moves
bool end(); // returns TRUE if this state is an end of game state
int heuristic(); // returns a heuristic value for the state
int whoseMove(); // returns the number of the player whose move is next from this state
// - the computer always plays as player 0.
string moveName(); // returns a string that describes the transition to this state from
// the parent state in textual form (for
// prompting users for their move).
gameState(int player); // constructor creating an opening state in
// which player makes the first move.
ostream& operator<<(ostream&,state&); // print the board
Your tree class must have at minimum the following interface:
int size(); // the number of nodes in the game tree that have been visited.
// Your tree must keep the tree
// for the whole game around, for analysis purposes.
nextMove(); // returns a gameState representing the next move.
// if the human player moves next, this
// method should prompt for the next move, otherwise
// compute it using minimax.
gameTree<gameState>(int player, int depth); // the constructor should initialize a game
// tree to a point before the first move, so that
// nextMove() sent to a new gameTree will return the
// opening state. The parameter indicates who gets to move
// first (0 is the computer).
// depth parameter specifies the fixed depth of the minimax search.
The main program will look something like this:
game = new gameTree<gameState>(1);
for(state = game->nextMove(); !state->end(); state = game->nextMove)
cout << state << endl;