Langton's Ant
I came across this in The Science of Diskworld. It involves an ant moving across a grid. If it moves into a white square it turns right, if it moves into a black square it turns left. In each case it toggles the colour of the square it enters.
For the first couple of hundred moves it goes around in little irregular circles. At this point it goes beserk with apparently random patterns of movement. Then suddenly, around 10,000 moves, it goes into a regular repeating pattern which will repeat to infinity. I've done a quick hack in javascript to show this (should work with Internet Explorer, no guarantees for other browsers). It's crude and it terminates when it hits the edge of a predefined grid but it suffices.
It is mainly interesting as an example of an emergent property - i.e. one which can't really be predicted. As an exercise for thought - if the initial grid is not plain white, will a repeating pattern always emerge? If not, why not? Even with a mindbogglingly simple algorithm such as this one it appears the great mathematical minds have no answer.
The source is here. Feel free to play with it and modify it to your heart's content. Let me know if you come up with anything interesting.
count = 0 timeout = 64ms
Stop Go Reset Slower Faster Fast as possible
Ant movement rules: enter square in front; if square is white, turn right, else turn left; toggle square colour. a curious thing happens after about 10,000 steps on a pure white background.
To experiment with different backgrounds, click on a square to toggle its colour.