00001 00002 00003 00004 00005 00006 00007 00008 00009 #include "MainGameFunctions.h" 00010 00011 void MainCreate(FCSPresetID GamePreset, FCCommandLineArguments* CommandLine, 00012 FCSFreecellSolvingAlgorithm** FreecellSolvingAlgorithm, 00013 FCSSimpleSimonSolvingAlgorithm** SimpleSimonSolvingAlgorithm, 00014 FCSTalonSolvingAlgorithm** TalonSolvingAlgorithm) 00015 { 00016 switch(GamePreset) 00017 { 00018 case FCS_PRESET_NONE: 00019 case FCS_PRESET_BAKERS_DOZEN: 00020 case FCS_PRESET_BAKERS_GAME: 00021 case FCS_PRESET_CRUEL: 00022 case FCS_PRESET_DER_KATZENSCHWANZ: 00023 case FCS_PRESET_DIE_SCHLANGE: 00024 case FCS_PRESET_EIGHT_OFF: 00025 case FCS_PRESET_FORECELL: 00026 case FCS_PRESET_FREECELL: 00027 case FCS_PRESET_GOOD_MEASURE: 00028 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00029 case FCS_PRESET_RELAXED_FREECELL: 00030 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00031 case FCS_PRESET_SEAHAVEN_TOWERS: 00032 *FreecellSolvingAlgorithm = FCSFreecellSolvingAlgorithm::Create(CommandLine); 00033 break; 00034 case FCS_PRESET_SIMPLE_SIMON: 00035 *SimpleSimonSolvingAlgorithm = FCSSimpleSimonSolvingAlgorithm::Create(CommandLine); 00036 break; 00037 case FCS_PRESET_KLONDIKE: 00038 *TalonSolvingAlgorithm = FCSTalonSolvingAlgorithm::Create(CommandLine); 00039 break; 00040 case FCS_PRESET_YUKON: 00041 case FCS_PRESET_BELEAGUERED_CASTLE: 00042 default: 00043 break; 00044 } 00045 } 00046 00047 FCSStateSolvingReturnCodes MainSolve(FCSPresetID GamePreset, FCSStateWithLocations *InitialState, 00048 FCSFreecellSolvingAlgorithm* FreecellSolvingAlgorithm, 00049 FCSSimpleSimonSolvingAlgorithm* SimpleSimonSolvingAlgorithm, 00050 FCSTalonSolvingAlgorithm* TalonSolvingAlgorithm) 00051 { 00052 switch(GamePreset) 00053 { 00054 case FCS_PRESET_NONE: 00055 case FCS_PRESET_BAKERS_DOZEN: 00056 case FCS_PRESET_BAKERS_GAME: 00057 case FCS_PRESET_CRUEL: 00058 case FCS_PRESET_DER_KATZENSCHWANZ: 00059 case FCS_PRESET_DIE_SCHLANGE: 00060 case FCS_PRESET_EIGHT_OFF: 00061 case FCS_PRESET_FORECELL: 00062 case FCS_PRESET_FREECELL: 00063 case FCS_PRESET_GOOD_MEASURE: 00064 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00065 case FCS_PRESET_RELAXED_FREECELL: 00066 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00067 case FCS_PRESET_SEAHAVEN_TOWERS: 00068 return FreecellSolvingAlgorithm->Solve(InitialState, 0); 00069 case FCS_PRESET_SIMPLE_SIMON: 00070 return SimpleSimonSolvingAlgorithm->Solve(InitialState, 0); 00071 case FCS_PRESET_KLONDIKE: 00072 return TalonSolvingAlgorithm->Solve(InitialState, 0); 00073 case FCS_PRESET_YUKON: 00074 case FCS_PRESET_BELEAGUERED_CASTLE: 00075 default: 00076 return FCS_STATE_DOES_NOT_EXIST; 00077 } 00078 00079 return FCS_STATE_DOES_NOT_EXIST; 00080 } 00081 00082 FCSStateSolvingReturnCodes MainResume(FCSPresetID GamePreset, 00083 FCSFreecellSolvingAlgorithm* FreecellSolvingAlgorithm, 00084 FCSSimpleSimonSolvingAlgorithm* SimpleSimonSolvingAlgorithm, 00085 FCSTalonSolvingAlgorithm* TalonSolvingAlgorithm) 00086 { 00087 switch(GamePreset) 00088 { 00089 case FCS_PRESET_NONE: 00090 case FCS_PRESET_BAKERS_DOZEN: 00091 case FCS_PRESET_BAKERS_GAME: 00092 case FCS_PRESET_CRUEL: 00093 case FCS_PRESET_DER_KATZENSCHWANZ: 00094 case FCS_PRESET_DIE_SCHLANGE: 00095 case FCS_PRESET_EIGHT_OFF: 00096 case FCS_PRESET_FORECELL: 00097 case FCS_PRESET_FREECELL: 00098 case FCS_PRESET_GOOD_MEASURE: 00099 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00100 case FCS_PRESET_RELAXED_FREECELL: 00101 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00102 case FCS_PRESET_SEAHAVEN_TOWERS: 00103 FreecellSolvingAlgorithm->IncreaseMaxNumberOfCheckedStates(); 00104 return FreecellSolvingAlgorithm->Resume(0); 00105 case FCS_PRESET_SIMPLE_SIMON: 00106 SimpleSimonSolvingAlgorithm->IncreaseMaxNumberOfCheckedStates(); 00107 return SimpleSimonSolvingAlgorithm->Resume(0); 00108 case FCS_PRESET_KLONDIKE: 00109 TalonSolvingAlgorithm->IncreaseMaxNumberOfCheckedStates(); 00110 return TalonSolvingAlgorithm->Resume(0); 00111 case FCS_PRESET_YUKON: 00112 case FCS_PRESET_BELEAGUERED_CASTLE: 00113 default: 00114 return FCS_STATE_DOES_NOT_EXIST; 00115 } 00116 00117 return FCS_STATE_DOES_NOT_EXIST; 00118 00119 } 00120 00121 00122 void MainOptimize(FCSPresetID GamePreset, FCSStateWithLocations *InitialState, FCSStateWithLocations *DuplicateInitialState, 00123 FCSFreecellSolvingAlgorithm* FreecellSolvingAlgorithm, 00124 FCSSimpleSimonSolvingAlgorithm* SimpleSimonSolvingAlgorithm, 00125 FCSTalonSolvingAlgorithm* TalonSolvingAlgorithm) 00126 { 00127 FCSOptimizeSolvingAlgorithm<FCSFreecellSolvingAlgorithm>* FreecellOptimize; 00128 FCSOptimizeSolvingAlgorithm<FCSSimpleSimonSolvingAlgorithm>* SimpleSimonOptimize; 00129 FCSOptimizeSolvingAlgorithm<FCSTalonSolvingAlgorithm>* TalonOptimize; 00130 00131 switch(GamePreset) 00132 { 00133 case FCS_PRESET_NONE: 00134 case FCS_PRESET_BAKERS_DOZEN: 00135 case FCS_PRESET_BAKERS_GAME: 00136 case FCS_PRESET_CRUEL: 00137 case FCS_PRESET_DER_KATZENSCHWANZ: 00138 case FCS_PRESET_DIE_SCHLANGE: 00139 case FCS_PRESET_EIGHT_OFF: 00140 case FCS_PRESET_FORECELL: 00141 case FCS_PRESET_FREECELL: 00142 case FCS_PRESET_GOOD_MEASURE: 00143 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00144 case FCS_PRESET_RELAXED_FREECELL: 00145 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00146 case FCS_PRESET_SEAHAVEN_TOWERS: 00147 FreecellSolvingAlgorithm->CleanData(); 00148 FreecellOptimize = new FCSOptimizeSolvingAlgorithm<FCSFreecellSolvingAlgorithm>(FreecellSolvingAlgorithm); 00149 FreecellOptimize->Solve(InitialState, 0); 00150 FreecellOptimize->TraceSolution(); 00151 FreecellOptimize->ShowSolution(InitialState, DuplicateInitialState); 00152 delete FreecellOptimize; 00153 break; 00154 case FCS_PRESET_SIMPLE_SIMON: 00155 SimpleSimonSolvingAlgorithm->CleanData(); 00156 SimpleSimonOptimize = new FCSOptimizeSolvingAlgorithm<FCSSimpleSimonSolvingAlgorithm>(SimpleSimonSolvingAlgorithm); 00157 SimpleSimonOptimize->Solve(InitialState, 0); 00158 SimpleSimonOptimize->TraceSolution(); 00159 SimpleSimonOptimize->ShowSolution(InitialState, DuplicateInitialState); 00160 delete SimpleSimonOptimize; 00161 break; 00162 case FCS_PRESET_KLONDIKE: 00163 TalonSolvingAlgorithm->CleanData(); 00164 TalonOptimize = new FCSOptimizeSolvingAlgorithm<FCSTalonSolvingAlgorithm>(TalonSolvingAlgorithm); 00165 TalonOptimize->Solve(InitialState, 0); 00166 TalonOptimize->TraceSolution(); 00167 TalonOptimize->ShowSolution(InitialState, DuplicateInitialState); 00168 delete TalonOptimize; 00169 break; 00170 case FCS_PRESET_YUKON: 00171 case FCS_PRESET_BELEAGUERED_CASTLE: 00172 default: 00173 break; 00174 } 00175 } 00176 00177 void MainSolution(FCSPresetID GamePreset, FCSStateWithLocations *InitialState, FCSStateWithLocations *DuplicateInitialState, 00178 FCSFreecellSolvingAlgorithm* FreecellSolvingAlgorithm, 00179 FCSSimpleSimonSolvingAlgorithm* SimpleSimonSolvingAlgorithm, 00180 FCSTalonSolvingAlgorithm* TalonSolvingAlgorithm) 00181 { 00182 switch(GamePreset) 00183 { 00184 case FCS_PRESET_NONE: 00185 case FCS_PRESET_BAKERS_DOZEN: 00186 case FCS_PRESET_BAKERS_GAME: 00187 case FCS_PRESET_CRUEL: 00188 case FCS_PRESET_DER_KATZENSCHWANZ: 00189 case FCS_PRESET_DIE_SCHLANGE: 00190 case FCS_PRESET_EIGHT_OFF: 00191 case FCS_PRESET_FORECELL: 00192 case FCS_PRESET_FREECELL: 00193 case FCS_PRESET_GOOD_MEASURE: 00194 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00195 case FCS_PRESET_RELAXED_FREECELL: 00196 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00197 case FCS_PRESET_SEAHAVEN_TOWERS: 00198 FreecellSolvingAlgorithm->TraceSolution(); 00199 FreecellSolvingAlgorithm->ShowSolution(InitialState, DuplicateInitialState); 00200 break; 00201 case FCS_PRESET_SIMPLE_SIMON: 00202 SimpleSimonSolvingAlgorithm->TraceSolution(); 00203 SimpleSimonSolvingAlgorithm->ShowSolution(InitialState, DuplicateInitialState); 00204 break; 00205 case FCS_PRESET_KLONDIKE: 00206 TalonSolvingAlgorithm->TraceSolution(); 00207 TalonSolvingAlgorithm->ShowSolution(InitialState, DuplicateInitialState); 00208 break; 00209 case FCS_PRESET_YUKON: 00210 case FCS_PRESET_BELEAGUERED_CASTLE: 00211 default: 00212 break; 00213 } 00214 } 00215 00216 00217 void MainStats(FCSPresetID GamePreset, 00218 FCSFreecellSolvingAlgorithm* FreecellSolvingAlgorithm, 00219 FCSSimpleSimonSolvingAlgorithm* SimpleSimonSolvingAlgorithm, 00220 FCSTalonSolvingAlgorithm* TalonSolvingAlgorithm) 00221 { 00222 switch(GamePreset) 00223 { 00224 case FCS_PRESET_NONE: 00225 case FCS_PRESET_BAKERS_DOZEN: 00226 case FCS_PRESET_BAKERS_GAME: 00227 case FCS_PRESET_CRUEL: 00228 case FCS_PRESET_DER_KATZENSCHWANZ: 00229 case FCS_PRESET_DIE_SCHLANGE: 00230 case FCS_PRESET_EIGHT_OFF: 00231 case FCS_PRESET_FORECELL: 00232 case FCS_PRESET_FREECELL: 00233 case FCS_PRESET_GOOD_MEASURE: 00234 case FCS_PRESET_KINGS_ONLY_BAKERS_GAME: 00235 case FCS_PRESET_RELAXED_FREECELL: 00236 case FCS_PRESET_RELAXED_SEAHAVEN_TOWERS: 00237 case FCS_PRESET_SEAHAVEN_TOWERS: 00238 cout << "Total number of states checked is " << FreecellSolvingAlgorithm->GetNumberOfCheckedStates() << "." << endl; 00239 cout << "This scan generated " << FreecellSolvingAlgorithm->GetNumberOfStatesInCollection() << " states." << endl; 00240 break; 00241 case FCS_PRESET_SIMPLE_SIMON: 00242 cout << "Total number of states checked is " << SimpleSimonSolvingAlgorithm->GetNumberOfCheckedStates() << "." << endl; 00243 cout << "This scan generated " << SimpleSimonSolvingAlgorithm->GetNumberOfStatesInCollection() << " states." << endl; 00244 break; 00245 case FCS_PRESET_KLONDIKE: 00246 cout << "Total number of states checked is " << TalonSolvingAlgorithm->GetNumberOfCheckedStates() << "." << endl; 00247 cout << "This scan generated " << TalonSolvingAlgorithm->GetNumberOfStatesInCollection() << " states." << endl; 00248 break; 00249 case FCS_PRESET_YUKON: 00250 case FCS_PRESET_BELEAGUERED_CASTLE: 00251 default: 00252 break; 00253 } 00254 }