A object for simulate the turing machine.

Implements

Constructors

  • Initialize machine with given arguments.

    Parameters

    • blank: TMSymbol

      A blank symbol. Both ends of the tape are (conceptually) initialized by an infinite sequence of this symbol.

    • ruleset: TMRuleSet

      Rules that determine how the head of the machine moves.

    • initState: TMState

      State of the machine when it starts to move.

    • acceptState: null | TMState = null

      State of the machine when the word is accepted.

    Returns TuringMachine

Properties

acceptState: null | TMState
blank: TMSymbol
halt: boolean = false
headPosition: number = 0
initState: TMState
initialWord: null | TMSymbol[] = null
nowState: null | TMState = null
ruleset: TMRuleSet
tape: null | TMTape = null

Methods

  • Returns a tuple representation of this machine.

    Returns {
        acceptState: null | TMState;
        blankSymbol: TMSymbol;
        initState: TMState;
        inputSymbolSet: Set<TMSymbol>;
        ruleset: TMRuleSet;
        stateSet: Set<TMState>;
        symbolSet: Set<TMSymbol>;
    }

    a tuple representation of this machine.

    Remarks

    A Turing machine is represented as follows:

    • stateSet - List of all states this machine uses.
    • symbolSet - List of all symbols this machine uses.
    • blankSymbol - A blank symbol.
    • inputSymbolSet - List of all symbols that can be used for words processed by this machine. (In this implementation, it is exactly the same as symbolSet.)
    • ruleSet - List of rules used by this machine.
    • initState - The state of this machine when it starts.
    • acceptState - The state when this machine accepts a word.
  • Returns whether this machine is in the accepted state.

    Returns boolean

    True if this machine is in the accepted state, false otherwise.

  • Returns whether this machine is halted.

    Returns boolean

    True if this machine is halted, false otherwise.

    Remarks

    The machine will stop if TuringMachine.isAccepted is true, but it is not treated as "halt".

  • Proceeds with this machine. This method must be called after TuringMachine.start called, or get an error,

    Parameters

    • step: number = 1

      Non-negative integer indicating how many steps to advance this machine.

    Returns void

    Remarks

    One "step" is a series of processes that reads a symbol, changes its state, writes the symbol, and moves the head.

  • Returns string representation of this machine.

    Returns string

    String representation of this machine.

Generated using TypeDoc