Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

players.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 *    FILE:     players.h
00003 *    AUTHOR:   CAL
00004 *    DATE:     29 April 1993
00005 *    PURPOSE:
00006 *      Declares the player hierarchy.
00007 ***********************************************************************/
00008 
00009 #ifndef _PLAYERS_H
00010 #define _PLAYERS_H
00011 
00012 #include <values.h>
00013 #include "moves.h"
00014 
00015 typedef int PosType;
00016 
00017 const int Invalid = MAXINT;
00018 const int NameSize = 40;
00019 const int MaxPlayers = 6;
00020 const int theSpy = 0;          // thePlayers [theSpy]
00021 
00022 /**********************************************************************
00023 *    CLASS:  Player
00024 ***********************************************************************/
00025 
00026 class Player
00027 {
00028   char Name [NameSize];
00029   int  Color;
00030 
00031 protected:
00032   PosType Pos;
00033   MoveList History;
00034   virtual Move ChooseMove (void) { return NullMove; }
00035   Player (void) { }
00036 
00037 public:
00038   Player (char* name, int color);
00039   Player (char* name, int color, PosType pos);
00040   virtual ~Player (void) { }
00041 
00042   PosType Position (void) { return Pos; }
00043   PosType GetPosition (void) { return Pos; }
00044   virtual bool IsSpy (void);
00045   char* GetName (void) { return Name; }
00046   int GetColor (void) { return Color; }
00047   MoveList& GetHistory (void) { return History; }
00048 
00049   virtual int NumTokens (TokenType) { return 0; }
00050   virtual Move TakeTurn (void) { return NullMove; }
00051 };
00052 
00053 
00054 /**********************************************************************
00055 *    CLASS:  Detective
00056 ***********************************************************************/
00057 
00058 class Detective : virtual public Player
00059 {
00060   int Tokens [NTokenTypes];
00061 
00062 public:
00063   Detective (void);
00064   bool IsSpy (void) { return False; }
00065   int NumTokens (TokenType t) { return (Tokens [t]); }
00066   Move TakeTurn (void);
00067 };
00068 
00069 
00070 /**********************************************************************
00071 *    CLASS:  Spy
00072 ***********************************************************************/
00073 
00074 class Spy : virtual public Player
00075 {
00076 public:
00077   bool IsSpy (void);
00078   int NumTokens (TokenType) { return Invalid; }
00079   Move TakeTurn (void);
00080   MoveList& GetHistory (void) { return History; }
00081 };
00082 
00083 
00084 /**********************************************************************
00085 *    CLASS:  Human
00086 ***********************************************************************/
00087 
00088 class Human : virtual public Player
00089 {
00090 protected:
00091   Move ChooseMove (void);
00092 };
00093 
00094 
00095 /**********************************************************************
00096 *    CLASS: Computer
00097 ***********************************************************************/
00098 
00099 class Computer : virtual public Player { };
00100 
00101 
00102 /**********************************************************************
00103 *    CLASS: HumanDetective
00104 ***********************************************************************/
00105 
00106 class HumanDetective : public Human, public Detective
00107 {
00108 public:
00109   HumanDetective (char* name, int color) : Player (name, color) { }
00110   HumanDetective (char* name, int color, PosType pos)
00111     : Player (name, color, pos) { }
00112 };
00113 
00114 
00115 /**********************************************************************
00116 *    CLASS: HumanSpy
00117 ***********************************************************************/
00118 
00119 class HumanSpy : public Human, public Spy
00120 {
00121 public:
00122   HumanSpy (char* name, int color) : Player (name, color) { }
00123   HumanSpy (char* name, int color, PosType pos)
00124     : Player (name, color, pos) { }
00125 };
00126 
00127 
00128 /**********************************************************************
00129 *    CLASS: ComputerDetective
00130 ***********************************************************************/
00131 
00132 class ComputerDetective : public Computer, public Detective
00133 {
00134 protected:
00135   Move ChooseMove (void);
00136   byte NumNodeTypes (int node);
00137   bool CanLeave (Move *duh);
00138   Move *FindNearest (int x, int y, MoveList *moves);
00139 public:
00140   ComputerDetective (char* name, int color) : Player (name, color) { }
00141   ComputerDetective (char* name, int color, PosType pos)
00142     : Player (name, color, pos) { }
00143 };
00144 
00145 
00146 /**********************************************************************
00147 *    CLASS: ComputerSpy
00148 ***********************************************************************/
00149 
00150 class ComputerSpy : public Computer, public Spy
00151 {
00152 protected:
00153   Move ChooseMove (void);
00154   Move *FindFarthest (int x, int y, MoveList *moves);
00155 public:
00156   ComputerSpy (char* name, int color) : Player (name, color) { }
00157   ComputerSpy (char* name, int color, PosType pos)
00158     : Player (name, color, pos) { }
00159 };
00160 
00161 
00162 /**********************************************************************
00163 *    Global array of players
00164 ***********************************************************************/
00165 
00166 extern Player* thePlayers [MaxPlayers];
00167 extern int NumPlayers;
00168 
00169 
00170 #endif

Generated on Sun Jul 6 23:07:16 2003 for Scotland Yard by doxygen1.2.15