A simple N-state two-color Turing machine which operates on a wrapped grid of black and white cells, and follows custom rules on every tick of a clock.
See http://turmites.destructuring-bind.org for a running example. By default one ant is automatically created; Extra ants may be added by clicking on the canvas.
Rules may be specified by adding a rule=...
parameter, of which some
permissible values are shown below.
langtons-ant (which has an implicit rule of 120080)
coiled-rope (implicit rule: 111180121010)
computer-art (implicit rule: 180121020081)
fibonacci (implicit rule: 181181121010)
worm-trails (implicit rule: 121181121020)
striped-spiral (implicit rule: 021080181020)
A full list of pre-defined rules can be found here. If no rule is given, then a pre-defined one will be selected at random. Or, alternatively, the rule definitions may be specified as a sequence of numeric digits, eg. http://turmites.destructuring-bind.org/?rule=021080181020
An N-state two-color rule consists of 2N triples, {a,b,c}, where:
a: the new color of the square
b: the direction(s) for the turmite to turn
c: the new internal state of the turmite
For example, the fibonacci turmite, has rule definition 181181121010 has two states and two colors, and is split into four triples {1,8,1}, {1,8,1}, {1,2,1} and {0,1,0}. The particulat triple is selected based on the current state and the current color. The {1,8,1} triple therefore states that the colour should change to 1, turn left (8) and adopt state 1 before moving forwards.
The direction to turn is specified by:
1: no turn
2: right
4: u-turn
8: left
The actions are specified by a state transition table listing the current internal state of the turmite and the color of the cell it is currently standing on. For example, the next rule-set to use for the fibonacci triples shown above are used by the following table:
current-color = 0 current-color = 1
current-state = 0 1,8,1 1,8,1
current-state = 1 1,2,1 0,1,0
So if the current state is 1 and the current color is 0, then the {1,2,1} triple is selected and the new color, direction and state are derived from that.
Invoke a noir instance using leiningen:
$ lein run
The clojure script will compiled down to javascript as part of the build, so browse to http://localhost:8080
Don't try to edit the javascript - it is compiled from ClojureScript
in src/turmites/client/core.cljs
using Leiningen with the lein-cljsbuild
plugin:
$ lein cljsbuild clean
$ lein cljsbuild auto
Refresh the page in the browser after having saved the file and allow for the compilation phase to complete.
Turmites are a generalization of Langtons-ants.
Inspired (in part) by Stephen Wolfram's, "A New Kind of Science", ISBN 1-57955-008-8
http://www.maa.org/editorial/mathgames/mathgames_06_07_04.html
http://code.google.com/p/ruletablerepository/wiki/TwoDimensionalTuringMachines
http://demonstrations.wolfram.com/Turmites/
https://en.wikipedia.org/wiki/Turmite
http://golly.sourceforge.net/
Copyright (c) Richard Hull 2012
Same as the eclipse public license - v 1.0: https://www.eclipse.org/legal/epl-v10.html