Finite State Machines model game flow, AI behaviour, or other processes using a set of discrete states and transitions between them.

A Finite State Machine is a set of states, each defining transitions to other states (may include themselves) and one of them being the final state, which defines no transitions (or optionally only transitions to itself).

Finite State Machines are frequently used to model:

  • AI decision making (where for example an agent may be in an idle or patrolling state until particular input provokes it to transition into an attacking or defending state)

  • Game and UI flow (where for example the main menu, options menus, character creation, gameplay pause screen, and modal dialogs are treated as states with UI interactions transitioning between them)

    • Especially in Interactive Fiction games, where the entire game structure is a directed graph which can often be usefully viewed as an FSM.
  • Collections or patterns of data (eg. using Finite State Transducers to store a compressed, searchable dictionary for a word game)

history | excerpt history