Turing Machine Simulator
What and why?
A small program for simulating a turing machine, mostly because I've been wanting to write one for a while now.
Usage
Input
The turing machine instructions should be in a newline-delimited text file with the following format:
{state} {tape-sym} {write-sym} {direction} {next-state}
Direction is either l
for left or r
for right.
Blank symbol is _
.
Other elements can be any arbitrary string.
The default start state is state 1.
Test cases
Put your test cases in another text file, newline delimited.
Sample Run
python tm_simulator.py {instructions} {test-cases}
See the tests/ folder for sample inputs
For more options, run
python tm_simulator.py -h
Output
Final output TBD. Currently just prints, but should instead return a DS to make simpler to build on top of it, e.g. GUI, shell, etc.
Todo
- Make TMSimulator.run return a sane output rather than just printing
- Separate classes into separate files for organization
- Let user set max step # to avoid infinite loop
- Gui for visualizing states and transitions
- Shell for loading instructions and testing tapes
- Commenting for input files
- Reachable exception