The history of the source code is interesting. It was called Zork and written in MDL. At some point they renamed it to Dungeon, but then a little while later named it back to Zork. During the time it was called Dungeon, a DEC engineer logged into their system (open to the world on purpose so people could play the game) but instead of playing the game copied the source code off. Then they translated the game into Fortran so they could run it on PDP-11s. This source code is the descendant of that translation.
Also referenced here: http://ifdb.tads.org/viewgame?id=4gxk83ja4twckm6j
Here is the full fortran code: http://gunkies.org/wiki/Zork#Source_code
<DEFINE WAIT ("OPTIONAL" (NUM 3))
#DECL ((NUM) FIX)
<TELL "Time passes...">
<REPEAT ((N .NUM))
#DECL ((N) FIX)
<COND (<OR <L? <SET N <- .N 1>> 0>
(defun wait (&optional (num 3)) ; same arglist
(declare (fixnum num)) ; similar declaration
(tell "Time passes...") ; some call
(repeat ((n num)) ; some loop macro, see below
(declare (fixnum n)) ; declaration
(cond ((or (< (setq n (- n 1)) 0) ; old-style COND, OR, <, SETQ, -
(clock-demon clocker) ; some call
(fighting fight-demon)) ; some call
(return))))) ; return from loop
(defmacro repeat (vars decl &body body)
(loop (progn ,@body))))
DEMUDDLE> (parse 'expr *lispm-expr*)
(DEFINE 'WAIT ("OPTIONAL" (NUM 3)) (TYPED DECL ((NUM) FIX))
(TELL "Time passes...")
(REPEAT ((N (LVAR NUM))) (TYPED DECL ((N) FIX))
((OR (L? (SET 'N (- (LVAR N) 1)) 0) (CLOCK-DEMON (GVAR CLOCKER))
(FIGHTING (GVAR FIGHT-DEMON)))
I also found the following interesting remark in the primer: "One of the implementors of Zork has been heard to say that Zork is a huge conditional".
- It's doing very complicated operations that operate on mutable global data, and structuring it as huge and deeply nested functions rather than splitting the operations up to smaller chunks with meaningful names. But you'd see exactly the same kind of thing in non-Lisp source code of that era; it's just different sensibilities.
- The code is incredibly heavy on conditionals. Which makes sense given the problem domain: parsing a pseudo-natural language. But MDL is a language where the conditionals kind of suck. COND is basically unreadable in any Lisp, you'd very rarely see people use it today. In CL you'd have more readable options like IF, WHEN and UNLESS. In MDL the only option is misusing short-circuiting AND/OR as a poor man's IF. Which they do in places, which doesn't help readability either.
- The use of angle brackets makes everything look like a sea of less-/greater -than comparisons. At least I just can't help it. It's especially bad when combined with the array indexing syntax.
I wouldn't say "very rarely"; COND is still used for multi-way conditionals. Virtually everyone I know would write:
(cond ((minusp x) 'negative)
((plusp x) 'positive)
(if (minusp x)
(if (plusp x)
(cond (pred then)
(cond (pred then))
(cond ((not pred) then))
(if pred then else)
(when pred then)
(unless pred then)
Beyond that, I'd have to read the language manual to make sense of notations like ,foo and .bar.
The code makes a lot of references to non-local names. Someone reading the code would benefit from being familiar with the semantics of what those denote.
What's going on in those functions isn't "rocket science" though.
While I was still working there we accumulated enough major change requests to the application that finally got the go ahead to throw the original code base out and start from scratch.
“This code is a forward-port of the Crowther/Woods Adventure 2.5 from
1995, last version in the main line of Colossal Cave Adventure
development written by the original authors. The authors have given
permission and encouragement for this release, it obsolesces all
the 350-point versions and previous 2.x (430-point) ports.”
I wish more people had this attitude to distracting things.
I suspect you mean both. And I agree. I'd probably agree with all permutations of meaning here, actually.
This is also a chapter in https://smile.amazon.com/Selected-Papers-Games-Lecture-Notes...
I would be lying if I said this was super easy to read. It is easy, though. Not sure if it is a good exposition for literate programming. I certainly like it, but I think I was predisposed to.
# On SCO Unix Development System 3.2.2a, the const type qualifier does
# not work correctly when using cc. The following line will cause it
# to not be used and should be uncommented.
Welcome to Dungeon. This version created 11-MAR-91.
You are in an open field west of a big white house with a boarded
There is a small mailbox here.
Most of these machines are dead because the power supply output capacitors have failed, but a fairly easy soldering job and they are back up and running. My original SCSI HD also failed (a 424MB Seagate ST1480N), but I've subbed in a SCSI2SD. Works a treat. I basically just play Nethack on it. I've also been experimenting with TeX 3.141 on it.
As far as a VM, I believe it is possible to run 4.1.4 within QEMU. I haven't personally tried, but I have had success in the past running some versions of Solaris 2.x for sun4m in QEMU. I believe you can emulate a SPARCstation 5 with tcx graphics fairly well with that.
Although a much smaller text adventure game would me more achievable.