#include <FCSFreecellData.h>
Inheritance diagram for FCSFreecellData:
Public Member Functions | |
virtual | ~FCSFreecellData () |
Destructor. | |
int | GetNumberOfCheckedStates () |
Get the number of check states in the solver. | |
int | GetNumberOfStatesInCollection () |
Get the number states in the solver. | |
void | IncreaseMaxNumberOfCheckedStates () |
Increase the max number of checked states allowed. | |
void | CleanData () |
Delete the current solution states to create room for an optimized solution. | |
virtual void | ShowSolution (FCSStateWithLocations *InitStateWithLocations, FCSStateWithLocations *DupStateWithLocations) |
Show the solution, step by step. | |
void | TraceSolution () |
Trace the solution from the final state down to the initial state. | |
Protected Member Functions | |
FCSFreecellData () | |
Default constructor. | |
void | InitFCSFreecellData () |
The "real" default constructor. | |
FCSFreecellData (FCCommandLineArguments *CommandLine) | |
Constructor with command line interface. | |
void | InitSolve (FCSStateWithLocations *InitState) |
Call this to initialize members needed for solve. (Common between all children). | |
int | GetNextMove (FCSStateWithLocations *StateWithLocations, FCSMove *Move) |
Get the next move of a SOLVED state. | |
FCSStateWithLocations * | StatePackAlloc () |
Allocate a state pack. | |
void | StatePackRelease () |
Release a state pack. | |
virtual FCSStateSolvingReturnCodes | CheckAndAddState (FCSStateWithLocations *NewState, FCSStateWithLocations **ExistingState, int Depth) |
If the state is new state (not generated before), add it to storage. | |
virtual void | CheckStateBegin (FCSStateWithLocations **NewStateWithLocations, FCSStateWithLocations *StateWithLocations, FCSMoveStack *Move) |
Prep a state to be added into storage. | |
virtual bool | CheckStateEnd (FCSStateWithLocations **NewStateWithLocations, FCSStateWithLocations *StateWithLocations, FCSDerivedStatesList **DerivedStateList, FCSMoveStack **Move, FCSMove **TempMove, int Depth, FCSStateSolvingReturnCodes *ReturnCode) |
Put the last move onto the move stack for the current state. | |
void | CreateTotalMovesStack () |
Create a move stack of all the moves in the game. | |
bool | IsParentCard (FCSCard *Child, FCSCard *Parent) |
is a card a parent of another? | |
int | CalculateMaxSequenceMoves (int FreecellNumber, int FreeStackNumber) |
Calculate the maximum number of sequence moves given the number of freecells and free stacks. | |
void | MoveSequence (FCSStateWithLocations *NewStateWithLocations, FCSCard *Card, FCSMoveStack *MoveStack, FCSMove **TempMove, int DestStack, int SourceStack, int Start, int End) |
Move a sequence of cards. | |
Protected Attributes | |
bool | IsOptimizeClass |
Is child class an optimize class? | |
FCStateType | m_StateType |
State type - Debug, Compact or Indirect. | |
AFCSStateWithLocationsMatrix * | m_StatePacks |
States used to solve the game. | |
int | m_MaxNumberOfStatePacks |
Maximum number of state packs before more memory has to be allocated for more. | |
int | m_NumberOfStatePacks |
Current number of state packs. | |
int | m_NumberOfStatesInLastPack |
Number of states in the last state pack. | |
int | m_StatePackLength |
Number of states in each pack. | |
int | m_NumberOfCheckedStates |
Number of states that were checked by the solving algorithm. | |
int | m_NumberOfStatesInCollection |
This is the number of states in the state collection. | |
int | m_MaxNumberOfStatesInCollection |
A limit on the number of states in the state collection. | |
AFCSStateWithLocationsMatrix * | m_SolutionStates |
A vector of the states leading to the solution. | |
int | m_NumberOfSolutionStates |
The number of states in m_SolutionStates. | |
FCSMoveStack * | m_SolutionMoves |
A move stack that contains the moves leading to the solution. | |
FCSMoveStack ** | m_ProtoSolutionMoves |
m_ProtoSolutionMoves[i] are the moves that lead from m_SolutionStates[i] to m_SolutionStates[i+1]. | |
FCSStateWithLocations * | m_FinalState |
This is the final state that the scan recommends to the interface. | |
int | m_MaxDepth |
Limits the maximal depth. | |
int | m_MaxNumberOfCheckedStates |
Limits the maximal number of checked states. | |
FCSDebugDisplayInfo * | m_DebugDisplayInfo |
m_DebugDisplayInfo provide a programmer with a programmable way to debug the algorithm while it is running. | |
int | m_TestsOrder [FCS_TESTS_NUM] |
The tests' order indicates which tests (i.e: kinds of multi-moves) to do at what order. | |
int | m_TestsOrderNumber |
Number of tests in the test's order. | |
AFCSGenericStateStorage * | m_StateStorage |
Used to store the previous states in a scan. | |
AFCSGenericStackStorage * | m_StackStorage |
Used to store stacks assuming Indirect Stack States are used. | |
int | m_NumberOfFreecells |
Number of freecells present in the game. | |
int | m_NumberOfStacks |
Number of stacks present in the game. | |
int | m_NumberOfDecks |
Number of decks present in the game. | |
BuildSequenceByEnum | m_SequencesAreBuiltBy |
What two adjacent cards in the same sequence can be. | |
bool | m_IsUnlimitedSequenceMove |
Whether an entire sequence can be moved from one place to the other regardless of the number of unoccupied Freecells there are. | |
FCEmptyStacksFillType | m_EmptyStacksFill |
With what cards can empty stacks be filled with. | |
bool | m_OptimizeSolutionPath |
A flag that indicates whether to optimize the solution path at the end of the scan. | |
CompareFunctionCompareNodesAlgorithm< FCSStateWithLocations, void > | m_CompareFunction |
Compare function used for comparing states. | |
MD5StateWithLocationsHashAlgorithm | m_MD5Hash |
Hash function used when storing in hash tables. | |
FCSIndirectCardCompareAlgorithm< FCSIndirectCard, void > * | m_IndirectCompare |
Compare function when storing FCSIndirectCards. | |
MD5HashAlgorithm< FCSIndirectCard > * | m_IndirectHash |
Hash function when storing FCSIndirectCards. | |
Friends | |
class | FCSOptimizeSolvingAlgorithm< FCSFreecellSolvingAlgorithm > |
added for every "optimized solving algorithm type" | |
class | FCSOptimizeSolvingAlgorithm< FCSSimpleSimonSolvingAlgorithm > |
added for every "optimized solving algorithm type" | |
class | FCSOptimizeSolvingAlgorithm< FCSTalonSolvingAlgorithm > |
added for every "optimized solving algorithm type" |
Definition at line 33 of file FCSFreecellData.h.
|
|
Reimplemented in FCSTalonSolvingAlgorithm. Definition at line 492 of file FCSFreecellData.cpp. References FCSStateWithLocations::CacheStacks(), FCSStateWithLocations::CanonizeState(), AFCSGenericStateStorage::CheckAndInsert(), m_MaxDepth, m_MaxNumberOfCheckedStates, m_MaxNumberOfStatesInCollection, m_NumberOfCheckedStates, m_NumberOfFreecells, m_NumberOfStacks, m_NumberOfStatesInCollection, m_StackStorage, and m_StateStorage. Referenced by CheckStateEnd(), and InitSolve(). |
|
Definition at line 436 of file FCSFreecellData.cpp. References FCSStateWithLocations::m_Depth, FCSStateWithLocations::m_MovesToParent, FCSMoveStack::Reset(), and StatePackAlloc(). Referenced by FCSFreecellSolvingAlgorithm::EmptyStackIntoFreecells(), FCSTalonSolvingAlgorithm::GetCardFromKlondikeTalon(), FCSFreecellSolvingAlgorithm::MoveCardsToADifferentParent(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToEmptyStack(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToFounds(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToTopOfStacks(), FCSFreecellSolvingAlgorithm::MoveNonTopStackCardsToFounds(), FCSFreecellSolvingAlgorithm::MoveSequencesToFreeStacks(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToFalseParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToFounds(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToParentOnTheSameStack(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithJunkSequenceAboveToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithSomeCardsAboveToTrueParent(), FCSFreecellSolvingAlgorithm::MoveStackCardsToAParentOnTheSameStack(), FCSFreecellSolvingAlgorithm::MoveStackCardsToDifferentStacks(), FCSFreecellSolvingAlgorithm::MoveTopStackCardsToFounds(), FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParent(), and FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParentWithSomeCardsAbove(). |
|
Definition at line 451 of file FCSFreecellData.cpp. References CheckAndAddState(), CreateMoveStack(), and StatePackRelease(). Referenced by FCSFreecellSolvingAlgorithm::EmptyStackIntoFreecells(), FCSTalonSolvingAlgorithm::GetCardFromKlondikeTalon(), FCSFreecellSolvingAlgorithm::MoveCardsToADifferentParent(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToEmptyStack(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToFounds(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToTopOfStacks(), FCSFreecellSolvingAlgorithm::MoveNonTopStackCardsToFounds(), FCSFreecellSolvingAlgorithm::MoveSequencesToFreeStacks(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToFalseParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToFounds(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToParentOnTheSameStack(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithJunkSequenceAboveToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithSomeCardsAboveToTrueParent(), FCSFreecellSolvingAlgorithm::MoveStackCardsToAParentOnTheSameStack(), FCSFreecellSolvingAlgorithm::MoveStackCardsToDifferentStacks(), FCSFreecellSolvingAlgorithm::MoveTopStackCardsToFounds(), FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParent(), and FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParentWithSomeCardsAbove(). |
|
Definition at line 374 of file FCSFreecellData.cpp. References ApplyMove(), m_NumberOfDecks, m_NumberOfFreecells, m_NumberOfStacks, m_SolutionMoves, and FCSMoveStack::Pop(). Referenced by ShowSolution(). |
|
Definition at line 359 of file FCSFreecellData.cpp. References m_NumberOfCheckedStates. Referenced by MainStats(). |
|
Definition at line 364 of file FCSFreecellData.cpp. References m_NumberOfStatesInCollection. Referenced by MainStats(). |
|
Reimplemented in FCSTalonSolvingAlgorithm. Definition at line 225 of file FCSFreecellData.cpp. References CheckAndAddState(). Referenced by FCSTalonSolvingAlgorithm::InitSolve(). |
|
Definition at line 523 of file FCSFreecellData.cpp. References FCSCard::GetCardNumber(), FCSCard::GetSuit(), and m_SequencesAreBuiltBy. Referenced by FCSTalonSolvingAlgorithm::GetCardFromKlondikeTalon(), FCSFreecellSolvingAlgorithm::MoveCardsToADifferentParent(), FCSFreecellSolvingAlgorithm::MoveFreecellCardsToTopOfStacks(), FCSFreecellSolvingAlgorithm::MoveSequencesToFreeStacks(), FCSFreecellSolvingAlgorithm::MoveStackCardsToAParentOnTheSameStack(), and FCSFreecellSolvingAlgorithm::MoveStackCardsToDifferentStacks(). |
|
Definition at line 546 of file FCSFreecellData.cpp. References FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), and FCSStateWithLocations::PushStackCardIntoStack(). Referenced by FCSSimpleSimonSolvingAlgorithm::MoveSequenceToFalseParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToParentOnTheSameStack(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParent(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithJunkSequenceAboveToTrueParentWithSomeCardsAbove(), FCSSimpleSimonSolvingAlgorithm::MoveSequenceWithSomeCardsAboveToTrueParent(), FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParent(), and FCSSimpleSimonSolvingAlgorithm::MoveWholeStackSequenceToFalseParentWithSomeCardsAbove(). |
|
Definition at line 250 of file FCSFreecellData.cpp. References FCSStateWithLocations::CleanState(), FCSMove::Create(), CreateTotalMovesStack(), DEBUG_DISPLAY_MOVES, DEBUG_DISPLAY_STATES, DEBUG_USE_STANDARD_NOTATION, AFCSStateWithLocationsMatrix::Delete(), AFCSStateWithLocationsMatrix::Get(), GetNextMove(), m_DebugDisplayInfo, FCSDebugDisplayInfo::m_DisplayDebugOptions, m_NumberOfDecks, m_NumberOfFreecells, m_NumberOfSolutionStates, m_NumberOfStacks, m_SolutionMoves, m_SolutionStates, FCSMove::MoveAsString(), FCSMove::MoveAsStringStandardNotation(), FCSMoveStack::Normalize(), and FCSStateWithLocations::StateAsString(). Referenced by MainSolution(). |
|
m_MaxDepth is quite dangerous because it blocks some intermediate moves and doesn't allow a program to fully reach its solution. Definition at line 154 of file FCSFreecellData.h. Referenced by FCSTalonSolvingAlgorithm::CheckAndAddState(), CheckAndAddState(), FCSFreecellData(), and InitFCSFreecellData(). |
|
m_MaxNumberOfCheckedStates is useful because it enables the process to stop before it consumes too much memory. Definition at line 160 of file FCSFreecellData.h. Referenced by FCSTalonSolvingAlgorithm::CheckAndAddState(), CheckAndAddState(), FCSFreecellData(), IncreaseMaxNumberOfCheckedStates(), and InitFCSFreecellData(). |
|
It gives a rough estimate of the memory occupied by the instance. Definition at line 126 of file FCSFreecellData.h. Referenced by FCSTalonSolvingAlgorithm::CheckAndAddState(), CheckAndAddState(), GetNumberOfStatesInCollection(), and InitFCSFreecellData(). |
|
It is created only after the solution was found by swallowing all the stacks of each depth. Definition at line 141 of file FCSFreecellData.h. Referenced by CreateTotalMovesStack(), GetNextMove(), InitFCSFreecellData(), ShowSolution(), and ~FCSFreecellData(). |
|
The State Packs variables are used by all the state cache management routines. A pack stores as many states as can fit in a 64KB segment, and those variables manage an array of such packs. Definition at line 106 of file FCSFreecellData.h. Referenced by FCSFreecellData(), InitFCSFreecellData(), StatePackAlloc(), and ~FCSFreecellData(). |