StateJS

State Machines for Javascript

StateJS is a Javascript library that provides state-based models such as Finite State Machines and the Subsumption architecture. It aims speed, low memory consuption and multi-agent control.

Download Github

Features

  • StateJS provide Finite State Machines, Subsumption Architecture and Utility Functions;
  • Extensible and Flexible, create new Machines or your own version of FSM or Utilities;
  • Optimized to control multiple agents, you can use a single machine instance to handle hundreds of agents;
  • Completely free, StateJS is published under the MIT License, which means that you can use it for your open source and commercial projects;
  • Lightweight, only 5KB!

Examples

// Creating a new Finite State Machine
var machine = new statejs.FSM();

machine.add('idle', new IdleState());
machine.add('obey', new ObeyState());
machine.add('run', new RunState());

// Creating a new State
var IdleState = statejs.State();
var p = IdleState.prototype;

p.tick = function(target, memory) {
  console.log("I'm Idle...");
}