Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FCSFreecellSolvingAlgorithm Class Reference

A algorithm class to solve freecell games.

#include <FCSFreecellSolvingAlgorithm.h>

Inheritance diagram for FCSFreecellSolvingAlgorithm:

FCSFreecellData FCSFreecellAlgorithm FCSTalonSolvingAlgorithm List of all members.

Public Member Functions

virtual ~FCSFreecellSolvingAlgorithm ()
 Destructor.

Static Public Member Functions

static FCSFreecellSolvingAlgorithmCreate (FCCommandLineArguments *CommandLine)
 Create a solving algorithm with CommandLine.

Protected Member Functions

 FCSFreecellSolvingAlgorithm ()
 Default constructor.
 FCSFreecellSolvingAlgorithm (FCCommandLineArguments *CommandLine)
 Constructor with command line interface.
void FlipTopCard (FCSStateWithLocations *State, int Stack, FCSMove *Move, FCSMoveStack **MoveStack)
 Check if the top card in the stack is a flipped card and if so flips it so its face is up.
virtual FCSStateSolvingReturnCodes RunTest (int TestNumber, FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 Function to run each test on a state.
FCSStateSolvingReturnCodes MoveTopStackCardsToFounds (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This function tries to move stack cards that are present at the top of stacks to the foundations.
FCSStateSolvingReturnCodes MoveFreecellCardsToFounds (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This test moves single cards that are present in the freecells to the foundations.
FCSStateSolvingReturnCodes MoveFreecellCardsToTopOfStacks (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This test moves single cards that are present in the freecells to the top of a stack.
FCSStateSolvingReturnCodes MoveNonTopStackCardsToFounds (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This test moves a single card from within a stack to a foundation.
FCSStateSolvingReturnCodes MoveStackCardsToDifferentStacks (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This moves cards from one stack to another.
FCSStateSolvingReturnCodes MoveStackCardsToAParentOnTheSameStack (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This test moves cards on a stack to a parent on the same stack.
FCSStateSolvingReturnCodes MoveSequencesToFreeStacks (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This tests moves a sequence to an empty stack.
FCSStateSolvingReturnCodes MoveFreecellCardsToEmptyStack (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 This tests moves a (group of) freecell card(s) to an empty stack.
FCSStateSolvingReturnCodes MoveCardsToADifferentParent (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 Move cards to a parent on a different stack.
FCSStateSolvingReturnCodes EmptyStackIntoFreecells (FCSStateWithLocations *StateWithLocations, int Depth, int NumberOfFreeStacks, int NumberOfFreecells, FCSDerivedStatesList *DerivedStateList)
 Put an entire stack into freecell cards.

Detailed Description

Definition at line 16 of file FCSFreecellSolvingAlgorithm.h.


Member Function Documentation

FCSFreecellSolvingAlgorithm * FCSFreecellSolvingAlgorithm::Create FCCommandLineArguments CommandLine  )  [static]
 

It is assumed that CommandLine has already been verified. This includes a valid start state

Parameters:
CommandLine is the command line object with all the information to solve a freecell game
Returns:
A pointer to a freecell solving algorithm.

Reimplemented in FCSTalonSolvingAlgorithm.

Definition at line 31 of file FCSFreecellSolvingAlgorithm.cpp.

References FCCommandLineArguments::GetSolvingMethodType().

Referenced by MainCreate().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::EmptyStackIntoFreecells FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 1400 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by RunTest().

void FCSFreecellSolvingAlgorithm::FlipTopCard FCSStateWithLocations State,
int  Stack,
FCSMove Move,
FCSMoveStack **  MoveStack
[inline, protected]
 

Parameters:
State with the stack
Stack position
Move to flip the card
MoveStack to add the move to

Definition at line 62 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSCard::GetFlipped(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSCard::SetFlipped(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by MoveNonTopStackCardsToFounds(), MoveSequencesToFreeStacks(), MoveStackCardsToDifferentStacks(), and MoveTopStackCardsToFounds().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveCardsToADifferentParent FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 1217 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CalculateMaxSequenceMoves(), FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::IsParentCard(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PushStackCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveFreecellCardsToEmptyStack FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 1158 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), CreateMoveStack(), FCSStateWithLocations::EmptyFreecell(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFreecellCard(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSMove::SetDestStack(), FCSMove::SetSourceFreecell(), and FCSMove::SetType().

Referenced by RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveFreecellCardsToFounds FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 186 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), CreateMoveStack(), FCSStateWithLocations::EmptyFreecell(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFoundation(), FCSStateWithLocations::GetFreecellCard(), FCSCard::GetSuit(), FCSStateWithLocations::IncrementFoundation(), FCSFreecellData::m_NumberOfDecks, FCSFreecellData::m_NumberOfFreecells, FCSMoveStack::Push(), FCSMove::SetFoundation(), FCSMove::SetSourceFreecell(), and FCSMove::SetType().

Referenced by RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveFreecellCardsToTopOfStacks FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 241 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FCSStateWithLocations::EmptyFreecell(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFreecellCard(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::IsParentCard(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceFreecell(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveNonTopStackCardsToFounds FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 382 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FlipTopCard(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFoundation(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSCard::GetSuit(), FCSStateWithLocations::IncrementFoundation(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfDecks, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetFoundation(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveSequencesToFreeStacks FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 963 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CalculateMaxSequenceMoves(), FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FlipTopCard(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackCardNumber(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::IsParentCard(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PushStackCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveStackCardsToAParentOnTheSameStack FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 696 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSCard::Copy(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FCSStateWithLocations::EmptyFreecell(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFreecellCard(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSCard::GetSuit(), FCSFreecellData::IsParentCard(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceFreecell(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveStackCardsToDifferentStacks FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 504 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CalculateMaxSequenceMoves(), FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FlipTopCard(), FCSCard::GetFlipped(), FCSStateWithLocations::GetFreecellCardNumber(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSFreecellData::IsParentCard(), FCSFreecellData::m_EmptyStacksFill, FCSFreecellData::m_NumberOfFreecells, FCSFreecellData::m_NumberOfStacks, min, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSStateWithLocations::PushCardIntoStack(), FCSStateWithLocations::PushStackCardIntoStack(), FCSStateWithLocations::PutCardInFreecell(), FCSMove::SetDestFreecell(), FCSMove::SetDestStack(), FCSMove::SetNumberOfCardsInSequence(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::MoveTopStackCardsToFounds FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected]
 

Parameters:
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Definition at line 119 of file FCSFreecellSolvingAlgorithm.cpp.

References FCSFreecellData::CheckStateBegin(), FCSFreecellData::CheckStateEnd(), FCSMove::Create(), FCSCard::Create(), CreateMoveStack(), FlipTopCard(), FCSCard::GetCardNumber(), FCSStateWithLocations::GetFoundation(), FCSStateWithLocations::GetStackCard(), FCSStateWithLocations::GetStackLength(), FCSCard::GetSuit(), FCSStateWithLocations::IncrementFoundation(), FCSFreecellData::m_NumberOfDecks, FCSFreecellData::m_NumberOfStacks, FCSStateWithLocations::PopStackCard(), FCSMoveStack::Push(), FCSMove::SetFoundation(), FCSMove::SetSourceStack(), and FCSMove::SetType().

Referenced by FCSTalonSolvingAlgorithm::RunTest(), and RunTest().

FCSStateSolvingReturnCodes FCSFreecellSolvingAlgorithm::RunTest int  TestNumber,
FCSStateWithLocations StateWithLocations,
int  Depth,
int  NumberOfFreeStacks,
int  NumberOfFreecells,
FCSDerivedStatesList DerivedStateList
[protected, virtual]
 

Parameters:
TestNumber to be run
StateWithLocations is the state to run the test on
Depth is the current depth of the state
NumberOfFreeStacks is the current number of free stacks in the state
NumberOfFreecells is the current number of freecells in the state
DerivedStateList is the current derived state list
Returns:
Solving return code

Implements FCSFreecellAlgorithm.

Reimplemented in FCSTalonSolvingAlgorithm.

Definition at line 77 of file FCSFreecellSolvingAlgorithm.cpp.

References EmptyStackIntoFreecells(), MoveCardsToADifferentParent(), MoveFreecellCardsToEmptyStack(), MoveFreecellCardsToFounds(), MoveFreecellCardsToTopOfStacks(), MoveNonTopStackCardsToFounds(), MoveSequencesToFreeStacks(), MoveStackCardsToAParentOnTheSameStack(), MoveStackCardsToDifferentStacks(), and MoveTopStackCardsToFounds().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 11:20:17 2005 for Cpp Freecell Solver by  doxygen 1.4.4