https://github.com/rgson/turing-machine
A simple, programmable Turing machine. [Prototype]
https://github.com/rgson/turing-machine
Last synced: 3 months ago
JSON representation
A simple, programmable Turing machine. [Prototype]
- Host: GitHub
- URL: https://github.com/rgson/turing-machine
- Owner: rgson
- Created: 2017-07-05T22:59:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-16T22:15:08.000Z (almost 8 years ago)
- Last Synced: 2025-01-15T08:19:27.660Z (5 months ago)
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Turing Machine Prototype
A virtual Turing Machine with it's own basic programming language.
## Language
Programs are specified in a simple programming language.
### Example
// Example program
foo [start]
1 -> 0 L foo
0 -> 1 L foo
_ -> _ N barbar [halt]
The example program inverts a binary number; all `1`s are replaced by `0`s and vice versa.
1. The program starts in the `foo` state, which is signalled by the `[start]` tag.
* If a `1` is read, the machine will write `0`, move the tape one step to the `L`eft and transition to the `foo` state (i.e. repeat the same state).
* If a `0` is read, the machine will write a `1` instead, move the tape to the left and repeat the `foo` state.
* If a blank space (`_`) is encountered, the blank character is written, the tape is `N`ot moved and the machine transitions to the `bar` state.
2. The machine halts upon entering the `bar` state, as signalled by the `[halt]` tag.### Description
* **States** are defined by a textual (alphanumeric) identifier. *Example:* `foo`
* **Instructions** occur within states and are triggered by a read character. They consist of one write, one move and one state transition. *Example:* `1 -> 0 L foo`
* **Symbols** constitute the alphabet used for reads and writes. They may be chosen arbitrarily. Underscore (`_`) is used as the default, "blank" symbol. *Example:* `1`
* **Moves** express the movement of the virtual magnetic tape, moving it either `L`eft, `R`ight or `N`ot at all.
* **Transitions** change the machine's state to alter its behavior.
* **Tags** express certain meta-data about states, i.e. where the program starts (`[start]`) and where it ends (`[halt]`).
If `[start]` is omitted, the first state is assumed to be the start state. If `[halt]` is omitted, a `halt` state will be implicitly defined to fill the role.
* **Comments** start with `//` and last until the next line break.