This is an implementation of Langton's ant for classic 68000-based Macintosh computers.
I developed it on a modern Linux machine using the Retro68 project. I tested it under System 6.0.8 on the Mini vMac emulator and on a real Mac Plus. The code was written such that it can also be compiled using THINK C 5.0, an era appropriate compiler running directly on a 68k-based Mac. See the sections on building below for more details.
The app allows you to start the ant with an empty grid, a grid filled with random dots, or a grid filled with random shapes. You can reverse the ant's movement (rewinding time), and paste in images for the ant to destroy. You can also draw lines and erase portions of the grid. The ant moves the fastest when running without MultiFinder.
This app was developed as part of a project to explore implementations of Langton's ant on multiple platforms (Classic Mac, Commodore 64, and a modern terminal emulator). See the article at nybble.org for more details.
The project includes an 800k disk image ready to run: LangtonsAnt.dsk.zip
It bundles the application, the source code, and a THINK C project.
You can also try the app in your web browser by running one of the emulated systems at Infinite Mac, and dragging and dropping the disk image there.
First, make sure you've downloaded and successfully built Retro68.
build.sh and edit the line that says
so that it points to the appropriate path on your system.
Execute the build script:
If successful, the new disk image appears as
If you have
LaunchAPPL set up (see the Retro68 description), you can automatically launch the app in an emulator by running:
$ ./build.sh --launch
The resource file for this project (
src/LangtonsAnt.proj.rsrc.bin) was created and edited in the classic Mac environment with ResEdit.
If you wish to make changes to the resource file, you can edit it in the emulator and then copy it from the disk image to the top-level
src directory using:
Similarly, you can copy the THINK C project file from the disk image to the top-level
Both scripts use the disk image in the build directory and assume that
path/to/Retro68-build/toolchain/bin is in your
Also, be aware that simply opening the
src folder from the disk image in the Finder (via the emulator or an actual Mac) can cause
LangtonsAnt.proj to change.
Even if you don't explicitly edit these files, copying them over from the disk image may cause them to change from git's perspective.
If you have THINK C installed on your classic Mac, building should be as easy as opening
LangtonsAnt.proj in the
src folder of the disk image, and choosing Project > Run or Project > Build Application...
The nifty MacFlim project has a bundled disk image that includes THINK C, ResEdit, and some other handy tools. It can even be used as a boot disk for your emulator. Thanks to Fred Stark for releasing the source code to this project.
Because this compiler is quite old, you can't use modern niceties like declaring variables wherever you want.
All variables have to be declared at the top of the block in which they're used.
This is probably most annoying in
for loops, where it's become convenient to declare the loop variable in the initialization step.
I had to modify
CMakeLists.txt to define
OLDROUTINENAMES in order to choose compatibly named versions of a few functions (
I spent more than a few hours trying to figure out what I assumed was a bizarre memory problem when the app kept crashing with an Illegal Instruction error. Eventually it occurred to me to look at the project settings in THINK C (Edit > Options...). If you're targeting really old Macs, make sure you've turned off Generate 68020 Instructions. Also, turn on 4-byte ints for good measure:
Langtons-Ant-68k-Mac is released under the GNU General Public License v3.