Class MinskyRegisterMachine

Implements the Minsky Register Machine, a Turing-complete computation model that operates on a finite number of registers containing non-negative integers. Programs consist of increment, decrement-and-branch, and halt instructions.

Implements

Constructors

  • Creates a new Minsky Register Machine with the specified number of registers and program. Validates that all register indices and instruction pointers in the program are within bounds.

    Parameters

    Returns MinskyRegisterMachine

    Throws

    If the number of registers is not positive or if the program contains invalid instructions

Properties

instructionPointer: number = 0
numberOfRegisters: number
registers: bigint[] = []

Methods

  • Executes the specified number of computation steps. Stops early if a HALT instruction is encountered.

    Parameters

    • step: number

      The number of steps to execute

    Returns void

    Throws

    If the machine has not been started or encounters an unknown instruction

  • Starts the machine with the specified initial register values. The instruction pointer is set to 0.

    Parameters

    • args: {
          registers: bigint[];
      }

      Object containing the initial register values as bigints

      • registers: bigint[]

    Returns void

    Throws

    If the number of registers provided does not match the machine's register count

Generated using TypeDoc