tree
svg code
dot code
Transitions, or edges, are the core of a state machine. Most states are implicitly declared by being in a transition.
On -> Off;
On
to a state called Off
On => Off;
On ~> Off;
On <-> Off;
On
to Off
, and one from Off
to On
On <=~> Off;
On
to Off
, and one main path from Off
to On
Red -> Green -> Yellow -> Red;
"Just today" -> "Tomorrow's list";
Actions, or events, allow the state machine to handle things through the machine structure rather than functional behavior.
On 'toggle' -> Off;
On
state, the toggle
action will cause a switch to the Off
stateOn 'toggle' -> Off 'toggle' -> On;
toggle action
which changes the state both ways between Off
and On
as appropriateRed 'proceed' -> Green 'proceed' -> Yellow 'proceed' -> Red;
proceed action
which cycles through a traffic light's colors automaticallySpread is a convenient way to write multiple similar edges at once.
Warrior -> [Barbarian Ranger Paladin];
Warrior
to the states Barbarian
, Ranger
, and Paladin
[Red Yellow Green] ~> Off;
Red
, Yellow
, and Green
to the state Off
[Asleep Awake Frightened] -> [Asleep Awake Frightened];
Asleep
, Awake
, and Frightened
to each other, including potentially themselvesThe machine itself has some attributes.
machine_name: "Example";
machine_author: "Bob <who@whom.example.com>";
machine_author: "Bob <who@whom.example.com>";