Of Ants and Turmites - An Introduction

06 March 2021

Langton’s Ant and Turk’s Turmites produce some fascinating designs from simple instruction sets. In the classic version, they live on a grid. Langton’s ant takes a step forward and turns either left or right depending on the color of the square it lands on. Stepping onto a square also toggles the square’s color. Langton’s Ant is usually done with black and white cell colors, but this can easily be replaced with any range of discrete states (more colors, integers, etc). Likewise, the simple left/right turn could also be extended with any number or order of operations (straight, back, diagonal, knight’s move, etc).

Basic Langton’s Ant

Color Direction
White Left
Black Right

Possible extension

Color Direction
Blue Right
Green Right
Yellow Straight
Orange Left
Red Left
Purple Straight

In this example, the colors rotate Blue->Green->Yellow->Orange->Red->Purple->Blue->Green->… Directions sets with repetition often produce regular, symmetrical designs.

Turmites go a step further to use an internal state in combination with its external state to choose its action. That action set can change internal and external states. Maybe it’ll increment the color 1 step, maybe it’ll “feel differently” in the next time step and will be influenced not to. Who knows? That was rhetorical, but the answer is that the static instruction set knows.

An example of instructions for a Turmite

  External State: N % 2 == 0 External State: N % 2 == 1
Internal State -> 0 Change External State
Keep Internal State
Keep Forward
Change External State
Change Internal State
Keep Forward
Internal State -> 1 Keep External State
Keep Internal State
Turn Right
Change External State
Change Internal State
Face Backward

On a field of 0’s, the turmite takes its first step forward. The internal state is 0, the external state is 0 so the turmite keeps facing forward and changes the external state but keeps the internal state. This is going to be a boring turmite. I’d defined my space with hard, terminal boundaries (like in the game Snake) instead of using rolling, connected edges (like Asteroid). This turmite will draw, but it’s not going to produce a pretty, pretty picture. Since it’s facing forward, it’ll continue walking onto untrod ground, changing it and walking forward. The turmite will only excercise these instructions, so the rest are irrelevant. It’ll make a line straight to the edge.


I’m going to turn exploration of this into a saga and hopefully provide some thought provoking content, inspiration to try to things for yourself, and maybe some pretty, pretty pictures.

Future topics:

  • Enumeration of instruction sets based on seed values
  • Some approaches to representation
  • Cheap algorithmic grouping or reduction of like images
  • Additional projects based on turmite outputs

Samples

Only thing left for this post is to show you some example output. This is across a spread of representation approaches and skips a WHOLE lot that are completely blank images, small solid squares or simple lines that fly out to an edge. Kept a lot of chaos at bay as well. Here’s a few to show the variety of outputs possible with just 4 instructions.

Click here to see the generated samples page