How often have you wished to have an instruction manual — or, at least, a Unix man page — for life? Well, your wait is over. Of course, you probably were hoping for instructions on how to navigate life, but [cve’s] mott program plays life inside a man page. That might not be as useful as a real manual for life, but it is still pretty cool.
To understand what’s happening, you have to understand how man pages work. They use an old form of markup known as roff
, which later begat nroff
and troff
. While roff
is made to do crude word processing at the dawn of Unix, it is also a Turing-complete language.
You do need groff
installed and, of course, man
. If you have all that, you can get a live demo with:
curl https://codeberg.org/cve/mott/raw/branch/main/mott.1 | man -l -
We’ll leave understanding all the macros involved as an exercise for the reader, but we are certainly impressed with the audacity of the idea and the implementation.
We would ask if it could play Doom, but we are afraid someone would answer yes and then show us. If you think markup is old-fashioned, don’t be too sure. (Although the underlying project is now at a new URL)
“While roff is made to do crude word processing at the dawn of Unix, it is also a Turing-complete language.” [emphasis added]
Note to self: Study the security implications of this, and promise to only use the knowledge obtained for good.
Don’t worry, I’m sure a scripting language designed in the 1970s is fully secure against malicious code :)
Doesn’t work in terminal on a Mac.
CAVEATS
At the moment, mott requires a groff(1) suite to function properly, meaning that the default man(1) utility will probably not work if you are on a BSD system, macOS or any other system using mandoc(1). Support for mandoc(1) and other, mostly legacy, roff(7) implementations is planned and largely depends on the removal of our usage of the while macros.
As seen on the grapse online man page tester (which also doesn’t work with this).
Clever. The original and best man page for Life (for me, at least) has been Martin Gardner’s article in Scientific American October 1970 https://www.ibiblio.org/lifepatterns/october1970.html
I implemented it back in college on a DEC VT-05 using the cursor control commands…from a program running on a CDC timesharing system.
I’d love to see the code, I’ve a bit of an implementation obsession.
Or even hear about any system quirks needing addressing.
Sadly, the code is lost to history. This was 50 years ago…the major challenge was avoiding the dinosaurs! I do remember that I had a current state and a next state array, and when an update cycle completed, I used the XOR of the two arrays so only the cells which changed got updated. This increased the update rate, which was important at 300 baud! A 24×80 array, as was the custom on those terminals.
The xor idea is excellent! It typically use a state buffer and 3 row buffers I think that Xor will let me efficiently check for change for the purpose of tracking if the state has become stale!
Read the story of a real programmer, Mel Kaye. In the early ‘90s I formatted the story and added it to the company machines so “man mel” returned the famous story as a man page. Section 8 of course.