Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
OpenSkyNet::AI::FSM Class Reference

#include <AIFSM.h>

Public Member Functions

 FSM (FSM_IDS fSMId_)
 
 FSM (FSM_IDS fSMId_, State &initialState_)
 
FSM_IDS getFSMId () const
 
bool setInitialState (State &initialState_)
 
State *& getInitialState ()
 
bool addState (State &currState_, int input_, State &nextState_)
 
StategetStateById (int Id_) const
 
int serialize (std::ofstream &fout_) const
 
int assemble (std::ifstream &fin_)
 

Static Public Member Functions

static void initAIFSMFileIO ()
 

Detailed Description

FSM - this class does not contain the transitions themselves (see State). The role of this class is to store the states, and populate States' transitions after making the following checks: 1) check if currState_ and nextState_ are in the FSM (to maintain uniqueness in _states) 2) HELP MAINTAIN MUTUAL EXCLUSIVITY OF STATE TRANSITIONS This is important; a state that can transition to more than one state per input has undefined behavior (at least logically, it will always go to the first state it "finds" - which depends on an implementation that may change).

Constructor & Destructor Documentation

FSM::FSM ( FSM_IDS  fSMId_)

constructor

Parameters
fSMId_the unique identifier for this machine
FSM::FSM ( FSM_IDS  fSMId_,
State initialState_ 
)

Member Function Documentation

bool FSM::addState ( State currState_,
int  input_,
State nextState_ 
)

ensures that all state transitions added maintain a connected graph with the initial state returns true if operation succeeded

Parameters
currState_the state to add a transition to (MUST already be in the FSM)
input_the input to cause a transition from the current state
nextState_the state to go to after receiving the input
int FSM::assemble ( std::ifstream &  fin_)

assigns this object to one read from a binary file and returns the number of bytes read

Parameters
fin_the file stream to read from (opened for binary input)
See Also
serialize()
FSM_IDS OpenSkyNet::AI::FSM::getFSMId ( ) const
inline

returns the _fSMId for this machine

State*& OpenSkyNet::AI::FSM::getInitialState ( )
inline

returns a pointer to the initial state if it has been set for this finite state machine, 0 otherwise

See Also
setInitialState()
State * FSM::getStateById ( int  Id_) const

returns 0 if Id_ is not found in the FSM

Parameters
Id_the state ID to look for
static void OpenSkyNet::AI::FSM::initAIFSMFileIO ( )
inlinestatic

must be called before any call to this classes' serialize or assemble methods

See Also
serialize()
assemble()
int FSM::serialize ( std::ofstream &  fout_) const

writes this object to a binary file and returns the number of bytes written

Parameters
fout_the file stream to write to (opened for binary output)
See Also
assemble()
bool FSM::setInitialState ( State initialState_)

the initial state MUST be set before any call to addState, either by this method, or by passing the initial state to the constructor. returns true if operation succeeded. the initial state is only set ONCE per instance of the class

Parameters
initialState_the initial State
See Also
getInitialState()

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