[size=9px]Seeing as how the AI forums have been dead quiet lately, I figured I'd revive this thread.[/size]

One of the ideas of a FSM (Finate State Machine) is to have a setting and a series of behaviors attached to that specific setting. You'd of course have a series of these and they would make up the whole of your FSM.

An example of how a state machine can be used is my robots main 'modes' in Subject 33.

These are some enumerated types from my game for use in my TRobot object. [size=9px](Sorry, I just like 'em! )[/size]

[pascal] TRobotState = (rsSearch, rsEvade, rsAttack, rsScan);
TRobotCharacteristics = (rcAggressive, rcEvasive, rcTactical);[/pascal]

TRobotState is my main setting for each robot. Each robot can be considered an individual state machine. The robot will perform the following actions when set to one of these settings:

rsSearch -- Set when the robot doesn't have anymore leftover objectives and has no idea where any of the players are. He goes about his code to search for more humans to kill. [size=9px](I use this as my default state because it's what the robot will find it's self doing most of the time.)[/size]

rsEvade -- Set when the robots feels it's time to back out and run. [size=9px](Most likely for self-preservation.)[/size] The robot will follow it's code that tells it how to run and hide from the player or threat(s).

rsAttack -- Set when the robot sees the opportunity to attack a player. He then follows his code that tells him how he should attack the player.

rsScan -- This one was added as an aid to the rsSearch mode. Instead of moving about to look for the player, the robot will instead stay still and use his other scanning means to find the players. This includes ultrasound, infrared, movement, etc. Once done if no player is found he'll go back to rsSearch mode.


Notice how each mode the robots does a different set of tasks? These are the individual States which make up the whole agent. Change the state, change the set of tasks and behaviors.

Also you'll notice that with each state you have a different means of switching between the different states.

Example:

In search mode:
if it sees a player he'll go into attack mode.
if some time goes by or he reaches a new checkpoint it'll go into scan mode.


In attack mode:
if it sees shots fired at him, it may go into evade mode.
if it loses the player, it will go back into search mode.

In evade mode:
if it no longer sees the shots and some time goes by, he may go back into search mode to find the player again.

And so on... I think you get the general idea.

Hope this fills up any blanks.