https://github.com/filipefernandes007/turing-machine
Turing Machine Javascript Implementation
https://github.com/filipefernandes007/turing-machine
turing-machine turing-machine-simulator
Last synced: about 1 month ago
JSON representation
Turing Machine Javascript Implementation
- Host: GitHub
- URL: https://github.com/filipefernandes007/turing-machine
- Owner: filipefernandes007
- Created: 2017-07-19T00:12:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-19T11:27:44.000Z (almost 9 years ago)
- Last Synced: 2025-12-02T17:37:00.216Z (7 months ago)
- Topics: turing-machine, turing-machine-simulator
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Turing Machine
##### Turing Machine Javascript Implementation
This implementation is based on wikipedia material: https://en.wikipedia.org/wiki/Turing_machine
Clone the repository and open index.html:
```sh
$ git clone https://github.com/filipefernandes007/turing-machine.git
$ cd turing-machine
$ open index.html
```
To use the javascript code in your own projects, all you have to do is
initiate turingMachine object and run it:
```javascript
turingMachine.init();
runner.run();
```
Look at the code - lib/turingmachine.js -, and you will find methods to add your own decision table (table state symbol):
- add an entry to the state/symbol table: ```turingMachine.table.addState(0, 'A', 1, 'R', 'B');```
The signature of this method is:
> addState(tapeSymbol, currentState, writeSymbol, moveTape, nextState)
- define the states like this: ```turingMachine.M.Q = ['A','B','C']; ```
- define the tape: ``` turingMachine.tape = [0,1,0,1,0,1]; ```
- put the header in a start position: ``` turingMachine.head = 0; // position 0 of the tape ```
- define the initial state register of the Turing machine: ``` turingMachine.stateRegister = turingMachine.M.q0; ```