//////////////////////////////////////////////////////////////////////////////
//
// File: player.h
//
// Purpose: This is the interface for the Player class, and the macros
//          related to it.  A player is any participant in the game.  The
//          referee is in fact a player (players[0] to be precise).
//
//          The following classes inherit from Player:
//
//            TradPlayer   - "traditional AI" player using top-down logic
//            NeuralPlayer - "neutral net AI" player using bottom-up logic
//            HumanPlayer  - human player (a user/tester of the program)
//            Referee      - moderator, responsible for enforcing game rules
//
// Authors:
//   txe  Travis Emmitt
//
// Modifications:
//   14-APR-1998  txe  Initial creation
//   15-APR-1998  txe  Added MOVE_* macros, added comments, alphabetized
//   16-APR-1998  txe  Added NewGame(), NewMatch(), GetNumWins()
//   18-APR-1998  txe  Now inherits from Debug
//   21-APR-1998  txe  Added num_draws, num_losses, ResetScores()
//   22-APR-1998  txe  Changed NEWBIE to ROOKIE ('n' is for neural)
//   23-APR-1998  txe  Improved constructor, added ability_loss_rate
//   24-APR-1998  txe  Removed ability
//
//////////////////////////////////////////////////////////////////////////////

#ifndef PLAYER_H
#define PLAYER_H

#include "common.h"
#include "board.h"
#include "debug.h"

#define MAX_ATTEMPTS    10	// max number of attempts at moving per turn
#define MAX_PLAYERS	    5  	// max number of players per game
#define MAX_WIN_BOARDS  10  // max wining configurations per game

#define PASS		    -2  // player wants to pass
#define QUIT		    -1  // player wants to quit

#define INVALID		0	 // move is invalid (against the rules)
#define LOSE		1	    // move causes you to lose
#define DRAW		2       // move doesn't cause you to win or lose
#define BLOCK      	3       // move lets you block opponent
#define WIN		    4       // move lets you win

///////////////////////////////////////////////////////////////////////////

class Referee;

class Player : public Debug {
protected:
  Board   *board;                       // the game board
  int      color;			// color (a number like 1 to 2)
  int      game;			// current game number
  int      match;                       // current match number
  int      move_x;                      // X-coordinate of current move
  int      move_y;			// Y-coordinate of current move
  int      num_draws;                   // number of times we've drawn
  int      num_losses;                  // number of times we've lost
  int      num_players;                 // number of players int the game
  int      num_win_boards;              // number of winning configurations
  int      num_wins;                    // number of times we've won
  Player  *players[MAX_PLAYERS];        // pointers to other players
  Referee *ref;                         // pointer to referee (player[0])
  int      size_x;                      // X size of the game board
  int      size_y;			// Y size of the game board
  int      turn;                        // current turn number
  Board   *win_boards[MAX_WIN_BOARDS];  // the winning configurations
  
public:
  Player (char *name, int color);
  int   GetNumDraws ();                 // returns our number of draws
  int   GetNumLosses();                 // returns our number of losses
  int   GetNumWins  ();                 // returns our number of wins
  void  ResetScores ();                 // resets # draws/losses/wins
  
  // virtual functions (each Player type can implement these differently) //
  
  virtual void Feedback (int code);     // provides feedback to the player
  virtual int  GetMove  () = 0;         // chooses our next move
  virtual int  NewGame  ();             // readies the player for a game
  virtual int  NewMatch ();             // readies the player for a match
  virtual void ShowPlayers (Player **players); // "introduces" other players
  virtual void ShowRules   (Board *board, Board **win_boards);
  virtual int  TakeTurn ();             // takes a turn (calls GetMove())
};

#endif

//////////////////////////////////////////////////////////////////////////////

