One Pager Cheat Sheet
- State machines, composed of States, Transitions, and Events, are mechanisms used to program a machine's response to a set of conditions and transition it from one state to another, illustrated in the example of an AC.
- Yes, a state machine can be used to program everyday appliances, by defining
states
,transitions
, andevents
. - A state machine is a logical system based on
states
,inputs
, andtransitions
that can be used to program everyday appliances without requiring any actual data or signal transmission. - The output of Meley and Moore state machines differs based on when they produce output - Meley when transitioning between states and Moore when entering and remaining in states.
- Meley state machines
produce output
during a transition between states, whereas Moore state machinesproduce output
when entering or remaining in a state. - Harel state charts enable hierarchy,
parallelism
, andbroadcasting
to be represented on the same diagram, allowing for more levels of abstraction than Meley and Moore state machines. - Acceptors are state machines that accept or reject some form of input, like a sequence of characters or tokens, by changing states and producing either a binaries output (such as even/odd) or n-ary output (e.g. classify the input into distinct classes).
- A fail state is always present in state machines, even if it is not
explicitly labeled
, and can beentered
if aninvalid character
isreceived
. - The
Acceptor
willverify
andconfirm
that an email is from a trusteddomain
, allowing it to pass if it is genuine or alerting the user if not. - A
Deterministic finite state machine (DFSM)
is a state machine that always gives the same output for the same input, while all other state machines are non-deterministic (NDFSM). - DFSMs cannot transition between states without
epsilon input
, unlike NDFSMs, which can transition without any input. - A deterministic state machine will always transition from the same set of inputs to the same state, whereas a
non-deterministic
state machine can transition to different states for the same set of inputs. - If the
output
of a state machine is not determined by the input due to the possibility of multiplestates
being transitioned to, then the machine is considered non-deterministic. - This code example demonstrates how a
state machine
with ahash map
can be implemented, with states corresponding to circles and transitions corresponding to arrows on a diagram. - Applications of state machines can provide various benefits, such as
language definition and analysis
,game development
,programming electronics
, andUI programming
, which can be used to detect valid input or switch between states such as Idle, Walk, Run, and Jump.