//******************************************************************************
//
// CS 240C : Spring 2003 Ohio University Travis Dillon
// Project 5 : Checkers
// file : game.h
// started : 00-00-00
// summary : This is a provided parent game class. It has virtual functions
// that are used in multiple board games
//
//******************************************************************************
#ifndef MAIN_SAVITCH_GAME
#define MAIN_SAVITCH_GAME
#include <queue> // Provides queue<string>
#include <string> // Provides string
namespace main_savitch_14
{
class game
{
public:
enum who { HUMAN, NEUTRAL, COMPUTER }; // Possible game outcomes
game( ) { move_number = 0; }
virtual ~game( ) { }
who play( );
protected:
virtual void display_message(const std::string& message) const;
virtual std::string get_user_move( ) const;
virtual who last_mover( ) const { return (move_number % 2 == 1 ? HUMAN:COMPUTER); }
virtual int moves_completed( ) const { return move_number; }
virtual who next_mover( ) const { return (move_number % 2 == 0 ? HUMAN :COMPUTER); }
virtual who opposite(who player) const { return (player == HUMAN) ?COMPUTER : HUMAN; }
virtual void make_move(const std::string& move) { ++move_number; }
virtual void restart( ) { move_number = 0; }
virtual void display_status( ) const = 0;
virtual bool is_game_over( ) const = 0;
virtual bool is_legal(const std::string& move) const = 0;
private:
int move_number; //tracks number of moves made, determines player
static const int SEARCH_LEVELS = 4; //level for look-ahead evaluation
void make_human_move( ); //makes the move if it is legal
};
}
#endif //MAIN_SAVITCH_GAME