State machines have been around in computer science for a long time. You'll find they are especially popular in reactive systems, like the software for video games and robotics. Designers use state machines to model a system using states, events, and transitions.
A state represents a situation or circumstance. In the screenshot below, we have a state machine with two states: a Power On state and a Power Off state. The machine will always be in one of these two states.
An event is some outside stimulus. In the screenshot above, we only have one type of event, a button‑click event. The state machine will respond to this event in either the Power On or the Power Off state. Not all states have to respond to the same events.
A transition moves the state machine to the next state. A transition can only occur in response to an event. Transitions don't have to move the state machine to a new state—a transition could loop back to the same state. When the machine receives...