Skip to content

A Langton's ant simulator written in C#

License

Notifications You must be signed in to change notification settings

cyotek/LangtonsAntSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Langton's ant simulator

The running simulation

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.

About Langton's ant

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)

About the code

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.

Simulation of twenty ants after 4000 moves

Simulation of twenty ants after 15000 moves

Acknowledgements

  • 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

About

A Langton's ant simulator written in C#

Topics

Resources

License

Stars

Watchers

Forks

Languages