/langtons-ant

a simple C implementation of Langton's Ant

Primary LanguageCDo What The F*ck You Want To Public LicenseWTFPL

What is this?

This is a simple implementation of Langton's Ant. Langton's ant is a two-dimensional universal Turing machine. Each ant is defined by a bitstring which has at least one zero and one one.

The classical ant is the two-bit string 10. After some time, it builds a repetitive pattern ("highway") and will leave the board. Ant 10

There are other behaviours, too. The ant 100 will be chaotic and slowly, but steadily grow. Ant 100

The ant 10001 is somehow chaotic, but also has some patterns. It slowly and steadily grows until it leaves the board. Ant 1001

This program takes any bitstring (<256 bits) as input and outputs an image in Portable Greymap Format. It will stop when the ant leaves the board or when the step count exceeds one billion.

Compilation

Should be as easy as typing make or gcc -O3 -o ant ant.c.

Usage

./ant 10 25
    Simulate Langton's Ant 10 on a quadratic board with size 25x25

./ant 110
    Same as above, but with default board size of 500