type: speed: 0

Langton's Ant

A generization to multiple colors

The original ant

Langton's Ant lives in an infinite grid of red and (a finite amount of) blue squares, and he can only take steps to neigbouring squares (that is, left, up, right or down). Moving takes three steps: first, he changes the color of the square he's standing on. Second, he takes one step forward to the next square. Last, he turns 90 degrees; clockwise if he's standing on a red square and anti-clockwise if he's standing on a blue square. It's as simple as that. On an empty grid, this would lead to a somewhat chaotic pattern, and eventually he'd create a regular pattern moving in a straight line, which is called the "highway". The (not yet proven) conjecture is that the ant always eventually makes that highway pattern, no matter what the configuration is at the start (note that the amount of blue squares stays finite).

The generization

We might generalize this idea to multiple colors by creating a list of indexed colors, and making the first step of the algorithm: the ant changes the color of the square he's standing on to the next color. We then define the ant by a sequence of R's and L's, where "R" stands for "Right", meaning the ant turns to the right (which is the same as rotating 90 degrees clockwise) and similar for "L". For example, the ant "RLL" is an ant, when landed on the first color turns right, on the second color left, and on the third color left.

How do I use this

Mouseover/scroll to the top of the page. A bar will fade in with 2 text fields and a "go"-button. In the first text field, enter the ant's type, for example "RL". In the second box, enter a speed the ant will be walking at in steps/millisecond, for example, 100. To begin, press "Go!". Warning: entering too high values for speed might not affect the actual walking speed but only makes the page laggy. You can adjust the speed by entering a new speed and clicking "Go!". This will not affect the current colors on the screen. On the top right of the screen, a number will appear indicating how many steps the ant has taken.

Some cool ants

I have checked all ants with a label of length 6 or less (see results in a txt file). I thought RLLR looked nice, but I was also surprised by RRLL. They are both symmetric, but RRLL tends to an apple-butt-like shape, and only grows bigger. The smallest square-filling "highway" is RRLRR. Wikipedia gives the following cool ones: LRRRRRLLR, LLRRRLRLRLLR, and RRLLLRLLLRRR. I found a couple more by entering "nice" sequences. I found RLRLRLRLRLRLR, which creates a nice highway. I also found RRRRRRRRRRLRRRRRRRRRLRRRRRRRRRR, which really surprised me, check it out!


Unfortunately, this tool doesn't work on . Try it on your desktop, it most probably works there!