Short: A little insect's Theory of Everything Author: Ragnar Fyri (ragnar.fyri@daf.no) Uploader: Ragnar Fyri (ragnar fyri daf no) Type: dev/amos Version: 1 Architecture: m68k-amigaos As all Discworld fans know, The Turtle Moves. Those who have read 'The Science of Discworld' know that The Ant Dances as well. Langton's Ant, which is discussed at some length on pages 98-99 of the aforementioned book (actually starting with the last few lines on page 97), is a little virtual insect whose main occupation in life is to prove that knowing a system's Theory of Everything does not necessarily mean you understand the system. Or something like that. At the start the Ant is described as 'now the star of a small computer program', but I could not find anything like it on Aminet (at least nothing with the name Langton in it), so I decided to have a try at a making an Amiga version. The Ant lives in a simple world which at the beginning consists entirely of white squares. Its mind is pretty simple too; it always moves according to these rules: 1) The Ant moves forward one step in the direction it is facing. 2) The square it lands on changes colour like an Othello tile, from white to black and vice versa. 3) If the square turns white, the Ant turns right. If the square turns black, the Ant turns left. 4) Lather, rinse, repeat.:-) The interesting thing is that these simple rules (the Ant's Theory of Everything) make the insect pass through three distinct phases, which the authors refer to as Simplicity, Chaos and Emergent Order. (I say the authors because I read this in their book, I suppose Langton used similar terms as well.) At first, the Ant creates simple patterns, and you think "Of course - simple rules make simple patterns; I saw that coming a mile away." That is, if you are a fast thinker or have a slow computer, because this phase only lasts for a few hundred moves. Then... Suddenly, chaos (or a reasonable facsimile) strikes, and the patterns turn (apparently) random. This phase lasts for about ten thousand steps, or about three seconds running my program uncompiled on a 68040. Which makes me wonder just how old the Ant is anyway, because the authors point out that 'if you computer is not very fast you may sit there for a long time'! Either they've tried running the program (not mine, the original) on a facsimile of Babbage's Differential Engine, or they have the patience of a mayfly, OR they're just quoting some 30 years old program notes. Anyway, at the end of move 10 291 a new kind of order emerges. Reaching the edge of what I call the Chaos Lump, the Ant suddenly falls into a repeating pattern of 104 moves, building a diagonal 'highway'. On a truly infinite board it will keep doing this forever, but since my program uses a finite screen with some simple wraparound, something new happens: When the Ant hits the Chaos Lump from the opposite side, it goes 'chaotic' again, then after a few thousand moves it starts a new highway at a different angle, which then runs into the old highway creating a new Chaos Lump... and so on. Pretty cool to watch really. :-) [The Short description above is actually short for "A little insect sets out to prove its Theory of Everything but ends up doing the 104step" Mwahahahaha.] --------------------------------------------------------------------------- Of course creating the basic program was just the beginning. There's a couple of variants here as well. Because the Ant moves so fast you'll miss the initial phase if you blink, I made one variant with a little delay to make it run more slowly. You'll have to wait a bit to see the highway on this version - 10 000 vertical blanks, to be precise (About 3 1/3 minute on a PAL system, a bit less on a NTSC system) Then I started playing with the rules. Did you notice that one of the rules rhymes - On white, turn right - while the other does not? On black, turn left What if I changed that to On black, turn back Well, it turns out to be pretty boring and an example of how you some times *can* predict a system's behaviour from its rules. Think about it - no left turns, only right ones? Obviously the Ant will be going nowhere fast. More precisely, it will go back, back and right in an endless loop, the two consecutive backscancelling out each other so you end up with a string of rights.. So that program is not included here. Instead I added a 'more advanced' variant. Of course there are three directions the Ant can choose (apart from the rather uninteresting 'back') so I tried making a three-colour version where the Ant can turn either left or right or continue straight ahead. (This is the 'tricolor' program) To save you a bit of time I can tell you right no that nothing special happens, it's just (apparently) chaotic from the beginning. But it's slightly more interesting than the 'go back' version, so I have included it anyway. Try it, maybe something does happen after a couple of hours! :-) Asker, September 2000 Ragnar Fyri ragnar.fyri@daf.no ICQ# 38891981