Skip to content
ionous edited this page Apr 7, 2016 · 11 revisions

hsm-statechart is a fast, lightweight, state machine implementation written in C, based on UML statecharts.

Motivation

There are other statechart implementations out there, so what's so good about hsm-statechart?

  1. A liberal license for games and indie development.
  2. The creation of state machines directly in code.
  3. An easy to understand hierarchical engine, with low policy requirements on user code.
  4. It's written in C and ports easily between OSX, Win32, and mobile platforms.

In addition hsm-statechart supports:

  • Zero dynamic memory allocation in its core API.
  • Optional per state instance data in the extended API.
  • A compact declarative interface.
  • [Lua] [ completely optional ]

The Stop watch tutorial provides a good overview of the system for both C and LUA. Event handlers provides more information on creating event handlers in C, and the Lua page provides more information on the Lua implementation.

Hsm builder provides a declarative interface above the core of hsm-statechart for more easily defining states.

The UML guide ( and Regions ) compares hsm-statechart's implementation with the UML statechart specification, while Resources provides links to more information about state charts, and other great projects.

There's also some thoughts on Future Work and C++ extensions, as well as a short list of Changes from prior versions.

Status of the code

The project hasn't been updated in quite a while. It still works, though, and could provide a good solution or starting point for some folks.

Clone this wiki locally