Perlin Ants

Perlin Ants with visible terrain

Click here to launch the ants.

Click the left square to generate a new terrain map.
Click the right square to show and hide the terrain map.

This is kind of a mash-up between bits and pieces of some previous experiments – the terrain from the tile-based game, and the ants from the Langton’s Ants experiments.

Basically, what is happening here is this: A thousand “ants” are created and placed in random locations on the screen, facing in random directions. Each turn, each ant moves forward one pixel. If the color of the new pixel is lighter than the previous pixel, it turns a bit widdershins. If the new pixel is darker, it turns a bit clockwise.

The ants end up tracing something like contour lines, and seem to be “attracted” to sections where the color of the terrain varies significantly over a small area.

I threw in a bit of a blur to make things more interesting visually.

Enjoy!