appkit  1.5.1
RoadNarrows Robotics Application Kit
StateStart Class Reference

Start state event class. More...

Inheritance diagram for StateStart:
State2_3Turing StateKb

Public Member Functions

 StateStart ()
 Constuctor.
 
virtual ~StateStart ()
 Destructor.
 
virtual void actionEnterState (int nPrefStateId, int nEventId)
 Execute 'enter state' action. More...
 
- Public Member Functions inherited from State2_3Turing
 State2_3Turing (int nStateId, const std::string &strStateName="", const std::string &strRefTag="")
 Initializatoin constuctor. More...
 
virtual ~State2_3Turing ()
 Destructor.
 
int readSymbol ()
 
void writeSymbol (int sym)
 
void moveHeadLeft ()
 Move head left one position on the tape.
 
void moveHeadRight ()
 Move head right one position on the tape.
 
void showTape ()
 Show colorized tape to stdout.
 

Additional Inherited Members

- Static Public Attributes inherited from State2_3Turing
static vector< int > Tape
 the tape of symbols More...
 
static int Head
 the tape read/write head
 

Detailed Description

Start state event class.

The start state is not part of the "official" (2,3) Turing Machine. Rather it is used to (re)initize the tape and then transition to the A state.

Definition at line 354 of file ut-sm.cxx.

Member Function Documentation

virtual void StateStart::actionEnterState ( int  nPrefStateId,
int  nEventId 
)
inlinevirtual

Execute 'enter state' action.

Parameters
nPrevStateIdPrevious state id.
nEventIdReceived event id.

Definition at line 375 of file ut-sm.cxx.

References EventIdSymbol.

376  {
377  Random rand;
378  int n;
379  int sym;
380  size_t i;
381 
382  Tape.clear();
383 
384  n = rand.randrange(0, 10);
385 
386  printf("\n");
387 
388  for(i=0; i<39-n/2; ++i)
389  {
390  Tape.push_back(EventIdSymbol[0]);
391  }
392 
393  for(i=0; i<n; ++i)
394  {
395  Tape.push_back(EventIdSymbol[rand.randrange(0, 2)]);
396  }
397 
398  for(i=Tape.size(); i<80; ++i)
399  {
400  Tape.push_back(EventIdSymbol[0]);
401  }
402 
403  Head = 41;
404 
405  showTape();
406  }
static vector< int > Tape
the tape of symbols
Definition: ut-sm.cxx:242
static const int EventIdSymbol[]
tape symbol event ids
Definition: ut-sm.cxx:88
static int Head
the tape read/write head
Definition: ut-sm.cxx:243
void showTape()
Show colorized tape to stdout.
Definition: ut-sm.cxx:307

The documentation for this class was generated from the following file: