00001 #ifndef FCS_MOVE_H 00002 #define FCS_MOVE_H 00003 00011 00012 #include "FCEnums.h" 00013 00015 #define FCS_MOVE_STACK_GROW_BY 16 00016 00017 #ifdef max 00018 #undef max 00019 #endif 00020 00021 #define max(a,b) ((a)>(b)?(a):(b)) 00022 00023 class FCSStateWithLocations; 00024 00026 class FCSMove 00027 { 00028 public: 00032 static FCSMove* Create(); 00033 00037 static FCSMove* CreateArray(int Size); 00038 00042 virtual void Copy(FCSMove* Move) = 0; 00043 00047 virtual unsigned char GetSourceStack() = 0; 00048 00052 virtual unsigned char GetSourceFreecell() = 0; 00053 00057 virtual unsigned char GetDestStack() = 0; 00058 00062 virtual unsigned char GetDestFreecell() = 0; 00063 00067 virtual unsigned char GetFoundation() = 0; 00068 00072 virtual FCSMoveTypes GetType() = 0; 00073 00077 virtual unsigned char GetNumberOfCardsInSequence() = 0; 00078 00082 virtual unsigned char GetNumberOfCardsFlipped() = 0; 00083 00087 virtual void SetSourceStack(unsigned char StackNumber) = 0; 00088 00092 virtual void SetSourceFreecell(unsigned char FreecellNumber) = 0; 00093 00097 virtual void SetDestStack(unsigned char StackNumber) = 0; 00098 00102 virtual void SetDestFreecell(unsigned char FreecellNumber) = 0; 00103 00107 virtual void SetFoundation(unsigned char FoundationNumber) = 0; 00108 00112 virtual void SetType(FCSMoveTypes MoveType) = 0; 00113 00117 virtual void SetNumberOfCardsInSequence(unsigned char NumberOfCardsInSequence) = 0; 00118 00122 virtual void SetNumberOfCardsFlipped(unsigned char NumberOfCardsFlipped) = 0; 00123 00127 void MoveAsString(char* String); 00128 00133 void MoveAsStringStandardNotation(char* String); 00134 }; 00135 00137 class FCSMoveStack 00138 { 00139 public: 00140 00142 virtual ~FCSMoveStack(); 00143 00150 void Normalize(FCSStateWithLocations* InitialState, 00151 int NumberOfFreecells, int NumberOfStacks, int NumberOfDecks); 00152 00156 virtual FCSMoveStack* Copy() = 0; 00157 00161 virtual void Push(FCSMove* Move) = 0; 00162 00167 virtual int Pop(FCSMove** Move) = 0; 00168 00170 void Reset(); 00171 00175 void SwallowStack(FCSMoveStack* SrcStack); 00176 00180 int GetNumberOfMoves(); 00181 00182 protected: 00184 FCSMoveStack(); 00185 00187 int m_MaxNumberOfMoves; 00188 00190 int m_NumberOfMoves; 00191 }; 00192 00196 FCSMoveStack* CreateMoveStack(); 00197 00205 void ReallocMoveStackArray(FCSMoveStack*** Array, int OldSize, int NewSize); 00206 00207 00215 void ApplyMove(FCSStateWithLocations* StateWithLocations, FCSMove* Move, 00216 int NumberOfFreecells, int NumberOfStacks, int NumberOfDecks); 00217 00218 #endif