This is my second implementation of a Langton's ant simulator, this time written in C#. I wrote it in 2011 for a C# Helper contest.
Langton's ant is a two-dimensional universal Turing machine with a very simple set of rules but complex emergent behavior.
Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the "ant". The ant can travel in any of the four cardinal directions at each step it takes. The "ant" moves according to the rules below:
- At a white square, turn 90° clockwise, flip the color of the square, move forward one unit
- At a black square, turn 90° counter-clockwise, flip the color of the square, move forward one unit
(Paraphrased from the Wikipedia page)
I haven't looked at this code in years, but I remember that I horribly over-engineered the thing originally. Interfaces everywhere!
However, I fired it up to take the screenshot at the top of this document and it still works perfectly fine.
- Rod Stephens of C# Helper for the idea in the first place (although I'm almost certain this is the second Langton's ant simulator I made, I'm sure I did one in Visual Basic 6, probably also for a Rod Stephens competition!)
- The ant icon used by the program by Martin Berube
- Yusuke Kamiyamane's Fugue Icons