fsm-util-lib - v1.0.0
    Preparing search index...

    Interface FSMConfig<TState, TInput>

    Configuration interface for creating a Finite State Machine (FSM).

    interface FSMConfig<TState extends string, TInput extends string> {
        alphabet: TInput[];
        finalStates: TState[];
        initialState: TState;
        states: TState[];
        transitionFunction: TransitionFunction<TState, TInput>;
    }

    Type Parameters

    • TState extends string

      The type of the states in the FSM.

    • TInput extends string

      The type of the input symbols the FSM can process.

    Index

    Properties

    alphabet: TInput[]

    An array of all possible input symbols that the FSM can accept.

    finalStates: TState[]

    An array of states that are considered final or accepting states. The significance of reaching a final state depends on the application of the FSM.

    initialState: TState

    The initial state of the FSM. The FSM starts processing input from this state.

    states: TState[]

    An array of all possible states in the FSM.

    transitionFunction: TransitionFunction<TState, TInput>

    A function that defines the transitions between states based on the current state and the input symbol. It is represented as an object where:

    • The keys are the current states.
    • The values are objects where:
      • The keys are the input symbols from the alphabet.
      • The values are the next states to transition to.
    // Example for the Modulo-Three FSM:
    const transitionFunction = {
    S0: { '0': 'S0', '1': 'S1' },
    S1: { '0': 'S2', '1': 'S0' },
    S2: { '0': 'S1', '1': 'S2' },
    };

    In this example, if the FSM is in state 'S0' and receives input '0', it stays in 'S0'. If it's in 'S0' and receives '1', it transitions to 'S1', and so on.