Skip to content

ngpal/turing-machine-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turing Machine Simulator

A simple command-line Turing machine simulator written in Rust.
It reads a transition table from a text file, asks for an input string, and simulates the machine until it halts.

Table of Contents

Build & Run

Build and run with cargo

cargo run -- <input file>

Input File Format

  • The first line lists the final (accepting) states, comma-separated.
  • Each subsequent line defines a transition in the format:
(current_state, read_symbol) -> (next_state, write_symbol, direction)
  • direction can be either < (move left) or > (move right)
  • _ represents a blank cell

Features

  • Parses Turing machine transition definitions from a plain text file
  • Uses a hash map for the transition table for fast lookups
  • Interactive simulation with live tape updates
  • Accept/reject halts based on final states

Implementation Notes

  • Tape length = 256 cells with wraparound
  • All uninitialized tape cells are _
  • Simulator starts in state q0 and halts when no valid transition exists
  • If the current state is in the list of final states, the machine accepts; otherwise, it halts with an error

Roadmap

  • Parse input files and run the machine
  • Instantaneous description
  • Turing machine variants

About

A turing machine simulator written in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages