Langton’s Ant is an interesting machine. It has simple rules, and makes nice patterns. So, it was an ideal test program for my 8080 emulator. When the finished program came-in at around 90 bytes, I realised that, if I could make it just a little smaller, it would fit in a tweet. (You can have 140 characters in a tweet, but because I wanted to tweet a hex-dump, I needed 2 characters per byte, so my target was 70 bytes.)
As you can see, I managed to get it down to exactly 70 bytes. I then spent a few hours trying to get it even smaller (so that I could fit a message in the tweet too), but eventually gave up.
Before showing the program running, I should, perhaps, explain what it does.
Langton’s Ant lives in a world of black and white squares. When he stands on a square, he changes its colour from black to white, or white to black. He then turns 90 degrees to the right if the square is black, or 90 degrees to the left if it’s white. Then he takes one step forward onto another square and does it all again.
The program should work as-is on any 8080 (or z80) emulator which has 32K of RAM. If you want to try it you need to load the program at address 0×0000, and watch for the output in the address range 0×4000 to 0×41ff. If you want to play with the source code it’s here. A slightly larger version with better animation is here.
Fortunately, the output happens to be exactly where the video memory is on my emulator. So, here’s a video of it in action.

Very cool!
Very very cool!
This brought back fond memories of 8 bit programming, which incidentally I am quite rusty with.
Elegant in its tightness, compared to the “bloat” that passes as code today.
Fool me once or twice. _Never_assume_ : a good solid lesson in life.
(Shame to me, I should have gotten The “halt” trick to sync the display.)
Anth