Arthromorphs
Notes on the original source code
by Alan Canon
The original source code was written in ThinkPascal with Quickdraw for the Macintosh. Pascal is a block structured programming language which can only do dynamic allocation using pointers to explicitly allocated quantities of memory. Collections of objects are represented by arrays of pointers to the dynamically allocated structures. The programmer must explicitly handle garbage collection when a data structure is no longer needed.
Written in a more modern programming language, the present translation project attempts to retain as much of the spirit of Richard Dawkins' original algorithm, while factoring out code which simply provided an object oriented infrastructure not supported by the original language. To transliterate the remaining code into Java, I copyied and pasted the Pascal source from the PDF file furnished by Dawkins, and then set about making the minimum changes required to translate each line into the nearest Java equivalent. Data type, variable and method names were preserved, and source code comments retained, where still applicable.
User interface code was largely factored out. And exception is made in the drawing routines that depict each animal on the computer screen, which are composed of Macintosh Quickdraw function calls. Rather than directly translate these calls into a different graphical user interface paradigm, a level of indirection was introduced in the form of a mock "Quickdraw" interface. This Java class contains method and constant names copied from the Quickdraw documentation. The interface does not specify exactly how the drawing is to take place, but only the names of the methods that the program calls to draw a rectangle, oval, or line segment for example. To make the program work with a particular user interface paradigm, the programmer must write a class which implements this interface, providing platform-specific drawing code which executes when the corresponding Quickdraw commands are invoked by the program. A reference implementation is provided using the Java Swing API. The program may then easily be ported to other graphical user interfaces, simply by writing a new implementation of the Quickdraw interface provided.
The core of the rewrite, since it uses only the Quickdraw emulator interface, is written to use only a subset of the Java standard API, excluding classes which are part of the Java graphical user interface library (AWT and Swing.) This reduced API is presently (2011) available for the Android platform, a port for which is planned in the near future. Additionally, the factoring out of GUI code from the main part of the program means that the program may be ported more easily to other computer programming languages than Java. The goal is to maximize the longevity of Dawkins' algorithm by providing as clean and concise presentation of it as possible.
Arthromorphs ThinkPascal Sources (original source code by Richard Dawkins and Ted Kaehler)