Fill in transition tables for storm-muddled village devices with Bang Dodi: 18 levels of state machines, transitions, guards and terminal states.
A state machine is always in exactly one state. An event triggers a transition to the next state, and which state that is depends on the current state. That is the heart of the State pattern: an object behaves differently depending on its state. You fill in the transition table: for each (state, event), the state it goes to. Bang Dodi then tests the device with its owner's test list, event by event.
Not every event makes sense in every state. An open door cannot be locked straight away; a locked door cannot be opened straight away. A transition you leave empty is not allowed: if it is forced, the machine jams. Limiting transitions is a safety feature: the State pattern keeps impossible states from happening.
Some states are terminal (absorbing): once the machine is in one, it never leaves. A Promise that is fulfilled cannot become rejected: settled is final. Model it by making every event in a terminal state lead back to that same state.
Many machines have a recovery path: a mistake throws you back to the start, but you may try again. Here every wrong goes back to s0 whatever the progress, while three right in a row reach open (a terminal state). Mapping the error transitions right keeps the machine from hanging in the wrong state.
locked and unlocked on the events coin and push.tick event.stopped, playing and paused.press.fulfilled and rejected final states (every event leads back to the same state).next) and back (back).reset → off in every state.And more, 18 levels in all.