FSM

From GameStudio Wiki

Jump to: navigation, search

Finite State Machines (FSM), in their simplest form, are made up of states and transitions between those states.


Contents

Advantages

  • Easy to use and understand on a small scale.

Disadvantages

  • Does not scale nicely. As new states are added or removed, all the other states need to be updated to reflect this (exploding complexity).


Implementation

Hard-Coded FSM

FSM can be implemented directly in the code (known as Hard-Coding). This can be done by representing each state as a function which is responsible for behavior and handling transitions to other states. Or the transitions can all be stored in a single function which is responsible for calling the correct state.

Data-Driven FSM

If you can abstract the states and transition conditions into simple values, you can use those values to represent your FSM rather than code.

Personal tools