Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finite State Machine: One State to Multiple States

I'm writing a simple finite state machine and realized that there are situations where an event can take a state to more than one possible results. Basically, from state A, if Event E happens, the state could be either C or D.

I'm currently using the Javascript Finite State Machine code written here: https://github.com/jakesgordon/javascript-state-machine

From the documentation I don't see an obvious way that makes this possible. More so, I feel like maybe this is actually a flow in my original design.

Essentially, in a Finite State Machine, should there be a situation where a transition happens, and based on some logic result in one of multiple states (1 to many), or should it be that we check the logic to see which transition needs to takes place (1 to 1)?

like image 858
beichenfan Avatar asked Apr 12 '16 00:04

beichenfan


People also ask

Can a state machine be in multiple states?

No. State machines have one state at a time. A combination state could be done with another state, like subscriber_and_promotional_period .

Can FSM have only one state?

Yes. The definition of an FSM allows unreachable states and allows having just one accepting state.

How many states does a finite state machine have?

Considered as a state machine, the turnstile has two possible states: Locked and Unlocked. There are two possible inputs that affect its state: putting a coin in the slot (coin) and pushing the arm (push).

How many initial states can be created in a state machine?

It consists of two states, Off and On. On is the initial state here; it is activated when the state machine is executed. The arrows between the states denote the possible state transitions. They define for which input a state change occurs.


1 Answers

Congratulations, you've just discovered non-deterministic finite state machines! The ideas are similar to that of a deterministic state machine, except that there may be multiple ways to transition from a state given the same input symbol. How this is actually done is unspecified (randomness, user input, branch out and run them all at once, etc.).

like image 91
JesseTG Avatar answered Oct 11 '22 19:10

JesseTG