JavaScript Turing Machine

So I was watching the anime series Ghost in the Shell and I don’t feel productive when I’m just watching anime, and I can’t write words when watching videos, so I decided to do some programming purely for fun.

What I did was write a little demonstration of a Turing Machine. Before there were computers, Alan Turing proved on paper that a machine could perform complex tasks. With a strip of paper divided up into places, the machine may read or write a symbol to its current place, move to another place, or change its state. This way it moves up and down the tape, reading and writing symbols, and, depending on its algorithm (instructions), performs calculations.


A Turing Machine

A Turing Machine

The table below is a JavaScript representation of one such machine. Using five tuples worth of instructions, the machine adjusts the ones and zeros to count upwards in binary. With eight positions on the tape, the machine can count up to 255. You may Start the demonstration, or Step through it. The + and symbols speed up or slow down the execution of steps.

The HTML page is located here. If you’d like to download the code, right click on the link, and select “Save link as…” and then edit the code in notepad to play with it. This code could certainly be written more elegantly, but Ghost in the Shell was pretty engaging, and the more basic code more appropriately speaks to the basic mechanics of what this demonstration is supposed to demonstrate.

If you don’t feel like rewriting JavaScript code, you can check out a programmable Java Turing Machine here, with instructions on its very simple programming language here.


Posted

in

by

Tags:

Comments

2 responses to “JavaScript Turing Machine”