RoRo-0.1: Lupupu Cube Stage SolverContentsIndex
Game.LupupuCube.Solver
Description
The engine of the Lupupu Cube solver.
Synopsis
data LupuGraph = LupuGraph {
lgSize :: !Size
lgGraph :: !Gr Depth Action
lgPhaseMap :: !Map Phase Node
lgPending :: !Set Pending
lgBestSolution :: !Maybe FinalState
lgInitialNode :: !Node
lgInitialPhase :: !Phase
}
type Depth = Int
data Pending = PEN !!Node !!Depth !Phase
data FinalState = FST !!Node !!Depth
type Solution = [(Action, Phase)]
data Action
= WalkLeft
| WalkRight
| JumpLeft
| JumpRight
isFinished :: LupuGraph -> Bool
numOfPendings :: LupuGraph -> Int
numOfStates :: LupuGraph -> Int
nextPending :: LupuGraph -> Maybe Pending
solveM :: Monad m => Stage -> LupuGraph -> m a -> m (Maybe Solution)
solve :: Stage -> Maybe Solution
ppAction :: Action -> String
Documentation
data LupuGraph
LupuGraph is a data structure which represents the intermediate state of stage solving.
Constructors
LupuGraph
lgSize :: !SizeThe size of stage.
lgGraph :: !Gr Depth ActionThe directed graph of state of the stage, which is usually incomplete (i.e. doesn't have every possible states).
lgPhaseMap :: !Map Phase NodeThe finite map from Phase to Node.
lgPending :: !Set PendingThe finite set of states which are known to be possible but not actually examined yet. At the time this set becomes empty, the stage is either solved or proven to have no solutions.
lgBestSolution :: !Maybe FinalStateThe best solution ever found, which has the shortest path to one of final states.
lgInitialNode :: !NodeThe Node of the initial state.
lgInitialPhase :: !PhaseThe initial state.
type Depth = Int
Depth is just an Int which represents a depth of node in a LupuGraph.
data Pending
Pending represents a state which is known to be possible but not actually determined yet. See lgPending.
Constructors
PEN !!Node !!Depth !PhaseThe Node of the state, the number of moves from the initial state to this state, and the state itself.
show/hide Instances
data FinalState
FinalState represents a final state.
Constructors
FST !!Node !!DepthThe Node of the state, and the number of moves from the initial state to this state.
type Solution = [(Action, Phase)]
Solution is a list of tuple (Action, Phase), representing the shortest path from the initial state to one of the final states.
data Action
Action is a data type to represent a way of state transition.
Constructors
WalkLeftWalk one step to left.
WalkRightWalk one step to right.
JumpLeftJump one step to left.
JumpRightJump one step to right.
show/hide Instances
Eq Action
Show Action
isFinished :: LupuGraph -> Bool
Returns True iff the given LupuGraph has no pending states.
numOfPendings :: LupuGraph -> Int
Returns the number of pending states of the given LupuGraph.
numOfStates :: LupuGraph -> Int
Returns the number of examined states of the given LupuGraph.
nextPending :: LupuGraph -> Maybe Pending
Returns the next pending state of the given LupuGraph if any.
solveM
:: Monad m
=> StageThe Stage to solve.
-> LupuGraph -> m aAn action to be called back repeatedly during the stage solving.
-> m (Maybe Solution)The solution if found.
Solves a Stage in a Monad with repeatedly applying an monadic action to the intermediate LupuGraph. The Monad is usually either IO or Identity. See also solve.
solve :: Stage -> Maybe Solution
Solves a Stage in an Identity monad with no-op callback. See also solveM.
ppAction :: Action -> String
Returns a brief representation of the given Action.
Produced by Haddock version 2.1.0