msmazes::NBitFSMBuilder<> Class Template Reference
[Core FSM Layer]

#include <msmazes/core/fsm/builder/n_bit.hpp>

List of all members.


Detailed Description

template<>
class msmazes::NBitFSMBuilder<>

An FSM Builder whose underlying pattern is an NBitPattern.

     typedef boost::mt19937
             RNGEngine;
     typedef msmazes::NBitFSMBuilder<>
             Builder;
     typedef Builder::Pattern
             Pattern;
     typedef sgdk::IndexTypeFSM<
                 boost::numeric::ublas::matrix<unsigned int>
               , unsigned int
             >
             FiniteStateMachine;
     RNGEngine          rng_engine;
     Builder            builder;
     FiniteStateMachine fsm;
     const Pattern&     pattern = builder.getPattern();
     builder.initialize(rng_engine, msmazes::StandardMazeMaker(), 5, 31, 0);
     fsm.initialize(builder);
     while (!fsm.hasReachedTargetState())
     {
         unsigned int state = fsm.getCurrentState();
         renderBitset(builder.getStateCell(state), pattern);  // User-defined
         int input = getInputFromUser();  // User-defined
         if ((-1 < input) && (input < pattern.getMaxOutDegree()))
         {
             fsm.processInput(input);
         }
     }
 

The code above will produce a PIN Code Maze with five switches. You start with all the switches turned on, and the goal is to turn them all off. Input consists of selecting a switch. The switch may toggle, or it may not; if none of the other switches work, then you've reached a dead end.

All programs using this class template must define BOOST_PARAMETER_MAX_ARITY as 6 or more.


Template parameters

Parameter Description Default
CellContainerSelector The type that will represent whether the cell container is a std::vector (in which case this type is boost::vecS) or a std::deque (in which case this type is boost::dequeS). boost::vecS
Block The integer type in which the bits of each cell are stored. unsigned long
Allocator The allocator type used for memory management of each cell. std::allocator<Block>


Model of


Type requirements



Public Types

typedef implementation_defined StateIndex
typedef implementation_defined InputIndex
typedef implementation_defined MazeGraph
typedef implementation_defined Pattern
typedef implementation_defined Cell
typedef implementation_defined Direction
typedef implementation_defined ArgumentValidationPolicy

Public Member Functions

 NBitFSMBuilder ()
 The default constructor.
virtual ~NBitFSMBuilder ()
 The destructor.
template<typename RNGEngine, typename MazeMaker, typename MazePolicy>
bool initialize (RNGEngine &rng_engine_arg, const MazeMaker &maze_maker_arg, const unsigned long init_bit_count_arg, const unsigned long init_bit_count_arg, const unsigned long init_bit_count_arg, const MazePolicy &maze_policy_arg)
template<typename Params>
bool initialize_with_named_params (Params &p)
const PatterngetPattern () const
const MazeGraphgetMazeGraph () const
bool isReady () const
template<typename TransitionFunction>
void buildTransitionFunction (TransitionFunction &transition_function) const
StateIndex getSourceState () const
StateIndex getTargetState () const
bool hasSolutionFromState (const StateIndex source_state) const
InputIndex getCorrectInput (const StateIndex source_state) const
const CellgetStateCell (const StateIndex state) const
Direction getStateDirection (const StateIndex state) const


Member Typedef Documentation

typedef implementation_defined msmazes::NBitFSMBuilder<>::StateIndex
 

The type representing the index of a vertex in the underlying maze graph, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::InputIndex
 

The type representing the index of an edge in the underlying maze graph, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::MazeGraph
 

The type of the underlying maze graph, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::Pattern
 

The type of the underlying pattern, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::Cell
 

The type of the cells in the underlying pattern, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::Direction
 

The type representing the course or bearing that is followed when traversing an edge in the underlying pattern's internal graph, as defined in the FSM Builder concept.

typedef implementation_defined msmazes::NBitFSMBuilder<>::ArgumentValidationPolicy
 

The Argument Validation Policy in effect, as defined in the FSM Builder concept.


Constructor & Destructor Documentation

msmazes::NBitFSMBuilder<>::NBitFSMBuilder  )  [inline]
 

Constructs this NBitFSMBuilder, but does not initialize it.

virtual msmazes::NBitFSMBuilder<>::~NBitFSMBuilder  )  [inline, virtual]
 

Destroys this NBitFSMBuilder.


Member Function Documentation

template<typename RNGEngine, typename MazeMaker, typename MazePolicy>
bool msmazes::NBitFSMBuilder<>::initialize RNGEngine &  rng_engine_arg,
const MazeMaker &  maze_maker_arg,
const unsigned long  init_bit_count_arg,
const unsigned long  init_bit_count_arg,
const unsigned long  init_bit_count_arg,
const MazePolicy &  maze_policy_arg
 

Initializes this NBitFSMBuilder. Violation of the specified preconditions will result in either compile-time errors or failed assertions unless otherwise noted.

Parameter Name Description Preconditions Default
rng_engine_arg A number generator used to build a random maze graph and, if required, random inputs.
maze_maker_arg The maze graph builder.
init_bit_count_arg The number of bits contained in each cell.
  • init_bit_count_arg < sizeof(Block) (This limitation is imposed by the implementation; in practice, even a low bit count of 6 can result in a maze of ample difficulty.)
init_entrance_cell_arg The value of the entrance cell.
  • init_entrance_cell_arg < ( 1 << init_bit_count_arg )
init_exit_cell_arg The value of the exit cell.
  • init_exit_cell_arg < ( 1 << init_bit_count_arg )
  • ( init_entrance_cell_arg != init_exit_cell_arg )
  • The entrance and exit cells cannot be connected to each other.
maze_policy_arg A maze policy associated with MazeMaker. The default policy associated with MazeMaker.

Returns:
true.
Note:
This class employs its own FSM Input Maker; you cannot replace it with another.

You can also pass the arguments by name. (In this case, it is recommended that you do so; otherwise, some of the arguments may be indistinguishable from each other.) Use the parameter table above to look up the parameter names. Remember that each parameter name resides in the msmazes namespace.

template<typename Params>
bool msmazes::NBitFSMBuilder<>::initialize_with_named_params Params &  p  )  [inline]
 

Initializes this NBitFSMBuilder via the specified Argument Pack object. See the initialize() function documentation for acceptable parameters.

const Pattern& msmazes::NBitFSMBuilder<>::getPattern  )  const [inline]
 

Returns a const reference to the underlying pattern, as defined in the FSM Builder concept.

const MazeGraph& msmazes::NBitFSMBuilder<>::getMazeGraph  )  const [inline]
 

Returns a const reference to the underlying maze graph, as defined in the FSM Builder concept.

bool msmazes::NBitFSMBuilder<>::isReady  )  const [inline]
 

Returns the readiness of this FSMBuilder, as defined in the FSM Builder concept.

template<typename TransitionFunction>
void msmazes::NBitFSMBuilder<>::buildTransitionFunction TransitionFunction &  transition_function  )  const [inline]
 

Builds the specified transition function according to the structure of the underlying maze graph and its property maps, as defined in the FSM Builder concept.

StateIndex msmazes::NBitFSMBuilder<>::getSourceState  )  const [inline]
 

Returns the finite state machine's source state, as defined in the FSM Builder concept.

StateIndex msmazes::NBitFSMBuilder<>::getTargetState  )  const [inline]
 

Returns the finite state machine's target state, as defined in the FSM Builder concept.

bool msmazes::NBitFSMBuilder<>::hasSolutionFromState const StateIndex  source_state  )  const [inline]
 

Indicates whether or not it is possible for the finite state machine to reach the target state from the specified state, as defined in the FSM Builder concept.

InputIndex msmazes::NBitFSMBuilder<>::getCorrectInput const StateIndex  source_state  )  const [inline]
 

Returns the input that brings the finite state machine one step closer to its target state, as defined in the FSM Builder concept.

const Cell& msmazes::NBitFSMBuilder<>::getStateCell const StateIndex  state  )  const [inline]
 

Returns the cell that the maze graph's cell index map pairs the specified state with, as defined in the FSM Builder concept.

Direction msmazes::NBitFSMBuilder<>::getStateDirection const StateIndex  state  )  const [inline]
 

Returns the direction from the last-visited cell to the cell that the maze graph's cell index map pairs the specified state with, as defined in the FSM Builder concept.


Multi-State Mazes in C++ is hosted by SourceForge.net. Use the Table of Contents for navigation.