// File: tictactoe.h (part of the namespace main_savitch_14) #ifndef MAIN_SAVITCH_CONNECT4 #define MAIN_SAVITCH_CONNECT4 #include // Provides queue #include // Provides string #include "game.h" // Provides the game base class namespace main_savitch_14 { class tictactoe : public game { public: // CONSTRUCTOR tictactoe( ); protected: // ******************************************************************* // VIRTUAL FUNCTIONS (these are overridden from the game base class) // ******************************************************************* // Return a pointer to a copy of myself: virtual game* clone( ) const; // Compute all the moves that the next player can make: virtual void compute_moves(std::queue& moves) const; // Display the status of the current game: virtual void display_status( ) const; // Evaluate the current board position. // NOTE: Positive values are good for the computer. virtual int evaluate( ) const; // Get the user's move as a string. virtual std::string get_user_move( ) const; // Return true if the current game is finished: virtual bool is_game_over( ) const; // Return true if the given move is legal for the next player: virtual bool is_legal(const std::string& move) const; // Have the next player make a specified move: virtual void make_move(const std::string& move); // Restart the game from the beginning: virtual void restart( ); private: // HELPER FUNCTIONS int value(int row, int column, int delta_r, int delta_c) const; // HELPER CONSTANTS. See tictactoe.cxx for their values. static const std::string MOVE_STRINGS[3][3]; // MEMBER VARIABLES TO TRACK THE STATE OF THE GAME char data[3][3]; }; } #endif