RGB Langton’s Ant(s)

Click the gif above to run your own simulation

Typically Langton’s Ant is a 2D grid based simulation using very simple rules to demonstrate complex emergent behaviour. It contains a single “ant” that uses the following rules:

  1. Move 1 grid square up, down, left or right
  2. If the square is white, the ant rotates its direction 90 degrees to the left
  3. If the square is black, the ant rotates its direction 90 degrees to the right
  4. Invert the colour of the swap, i.e. black becomes white, white becomes black
  5. Repeat for whatever length of time you’d like

Despite these very simple rules the ant will demonstrate quite complicated behaviour. Typically the ant progresses through phases of creating interesting geometric patterns, then moving more randomly and finally a “highway” pattern emerges that repeats indefinitely. YouTube is full of long running simulations if you’re interested in them.

RGB Ants

This was a quick afternoon’s worth of a prototype of an idea for ProcJam 2021 where the theme was “Change”. What’s the point of paying for hosting if you don’t post half formed ideas from time to time! I don’t remember why I decided to experiment with Langton’s Ant. Anyhow, I modified the original idea in the following ways:

  1. There are multiple ants to start with and the User can add more at any time.
  2. Ants are randomly assigned an initial colour: Red, Green or Blue.
  3. If the square is black, change it to the ant’s current colour
  4. If the square has a colour, that isn’t the ant’s current colour then blend it with ant’s current colour
  5. If the square is the ant’s current colour, change it to black.

I used chroma.js to help with blending colours. The deltaE function returns the difference between colours. I used maximum difference value to determine when to apply rules 4 and 5 because some colour differences were so slight (and imperceptible to my eyes at least) the changes – especially rule 5 – looked broken.

Get In Touch