FSM Creator 1.0

Copyright (C) 2004 Dylan Blair
email: dblair@alumni.cs.utexas.edu

This is a visual authoring tool for creating AI state machines based on premises and boolean logic.
It can export the state machines as C++ code. This code is not standalone. It uses an AI library,
(the FSM API, distributed separately), to wrap other game objects with an AI class and control their
actions depending on an object's state. The in-game implementation of the states' transitional inputs
is via an exception handling mechanism by objects in the game loop. Along with its current state, an
object with an AI wrapper also contains a knowledge base that stores the premises (exceptions) that
it receives. Thus, the state machines' inputs may come from premises that have spawned at any time
in the object's life.

Workflow for using FSMs in your C++ projects

Use FSM Creator to create state machines OR Write the files AIManager.h, AIManager.cpp, and AIConsts.h yourself, perhaps using the FSM API demo code as a basis for your own
Export the code and place the files in the same directory as the FSM API source files   |
Use the serialize project (comes with the FSM API) to create a binary file called a compiled finite state machines file (*.cfsm) OR
Leave the finite state machines represented as code only
Code and build a program using the FSM API and library. See the example FSM API demo code for details.
Modify your state machines if necessary
If your program initializes the AI engine using a .cfsm file, you do not have to rebuild the FSM library UNLESS AIConsts.h has NEW enum values   You must rebuild the entire FSM library again

Workflow for this tool

1. Think of a name for your FSM that describes the behavior of the entity that will use it (e.g. GUARD_PATROL)

2. Toggle the New State button, add a few states that represent (in general) a breakdown of things the entity could do (e.g. STAND_AT_GATE, WALK_PAST_VENDING_MACHINE, etc.). The states will not themselves be labeled descriptively, only numbered in the order of creation. To label a state more descriptivley and to decide what a state represents you...

3. Add actions. Click on each state, type in a specific thing any entity in this state should do while in this state. You can break down an action into parts, so that different states may have the same actions in general, but differ in the specifics (e.g. Name an action STAND with possible parameters AT_GATE or IN_HALLWAY. Name an action WALK with perhaps PAST_VENDING_MACHINE as a parameter). NOTE: You are not specifying HOW to do things with this tool, only WHAT. The implementations of the actions are done with the C++ FSM API.

4. Define Rules and set transitions (see below), that determine how you get from one state to the other. Example: if the AI entity hears something in the game, then go from a state that stands to one that walks to the noise. This is implemeted by having an exception thrown in the game when the noise happens (such as NOISE_IN_HALLWAY) and defining the rule as IF NOISE_IN_HALLWAY, THEN GOTO_STATE_CHECK_NOISE. You then create a transtion from the state that stands to one that walks to the noise using GOTO_STATE_CHECK_NOISE as the input.

5. If you use a lot of rules, break them up into different sets called logic processors.

Brief overview of this tool's functionality

This tool uses a .fsm extension for file saving. Do not confuse this with the .cfsm extension used
by the serialize executable listed above. Just remember that the 'c' stands for compiled.

States Tab

Toolbar Buttons
New FSM - Create a new finite state machine.
Rename FSM - Rename the current finite state machine.
New State - Toggling on enables creating a new state by pressing down on the white area. The states are auto numbered in the order they are created.
Add Action - This describes an action the game object will do every time the AI object's doAction() method is called on its state. These actions (enum values) must be implemented in-game. The AI class only says what must be done, not how.
Add Transition - A rule must be defined first (see below). A rule takes as input premises that spawn in-game (via exceptions) and returns a state input value. This state input value causes the state transitions. To define a transition, toggle the button on, choose the input from the bottom right dropdown box, then drag and drop between states. The first state dragged from is the initial state of the FSM. The initial state will have a blue outline when unselected, green otherwise. You may then only drag and drop states that maintain a connected graph. Epsilon transitions are not implemented.
Remove Transition - like the button label says
New Logic - A logic processor converts premises (exceptions) into state transition inputs. It is merely a set of rules. A FSM can have ANY logic processor (i.e. rules set) associated with it in-game via the FSM API. The only connection in this tool between the states of a finite state machine and the logic/rules which govern its transitions is that the states' inputs are a consequent of one of the rule's antecedent list being all true (see below).
Define Rule - An antecedent is defined as a premise plus other parameters such as allowing for the premise to expire. A rule has this format:
IF (antecedent1 AND antecedent2 AND ...), then (return the consequent state input, possibly add premises to the object's knowledge base, and possibly remove premises from the object's knowledge base)

NOTE: At minimum, a rule needs one antecedent and the consequent state input. It does not require anything else.

Other Actions/Notes
To Select a State - for adding and/or viewing its actions, left click on it. It will now have a green outline.
To Delete a State - Select it, and press the delete key.
To change the order of Actions and/or Action parameters for a state - Select the action or parameter. Hold down shift, and use the up and down arrow keys.

NOTE: A FSM that has all of its transitions removed will no longer have the initial state set.
NOTE: ALL names and other data entered into text fields MUST contain NO SPACES!

Rules Tab

Choosing a rule from the Rule # dropdown changes the contents of the other rule specific dropdowns.

Delete Rule - If this rule's consequent state input is unique, then all state transitions based on that input will be deleted, and any resulting disjoint transition sets will be deleted.
Remove this Rule from Logic in list above - like the label says
Rename Logic - Rename the logic listed in the All Logic Processors dropdown.
Delete Logic - The set of rules for which this was the only logic will not be deleted, but will no longer be exported until a logic contains it again.
Add current Rule to this Logic - Adds the rule in the Rule # dropdown to the logic in the All Logic Processors dropdown.

NOTE: A new rule will be automatically contained by the default (first) logic listed in the All Logic Processors list.
NOTE: If a rule is not associated with any logic processor, it will not be exported.