version 1/080105 by Michael Hilborn
Example: *** Mark II - A recreation of a legendary event in computer history.
Include Simple Debugger by Michael Hilborn.
[A common myth of computer lore is that the term "computer bug" was first coined by Admiral Grace Hopper on September 9, 1945 after discovering that a glitch in the Harvard Mark II machine was caused by an errant moth. Although the glitch was indeed the fault of the insect, there are several inaccuracies in this modern legend. First, the year was 1947, not 1945. Second, Hopper did not discover the bug; it was discovered by one of her colleagues, William "Bill" Burke--Hopper just enjoyed retelling the tale. Finally, the term "bug", as applied to electronic defects, had been around since the late nineteenth century.
It is true that the insect in question was taped to a logbook and annotated, "first actual case of bug being found."
In this example, we re-imagine what might have happened that fateful day...
[Here we seed the random number generator, then initialize and activate the debugger. The objects that we will be debugging in this example are the moth and the tape dispenser.]
When play begins:
seed the random-number generator with 1234;
initialize debugger, activating object-debugging.
[First, we create the lab and some scenery.]
The east lab is a room with the printed name "Harvard Mark II (East)". "The Harvard Mark II computer dominates the north side of the lab. Its metal array of switches and dials extends off to the west[if the dead moth is on the relay panels], from which emanates the unpleasant smell of something burning[end if][if the Harvard Mark II is not working]. The computer lies dormant[end if]."
The west lab is a room with the printed name "Harvard Mark II (West)". The west lab is west of the east lab. "The Harvard Mark II computer dominates the north side of the lab. Its metal array of switches and dials extends off to the east. Among the maze of metal and wire are some relay panels[if the dead moth is on the relay panels], among which a wisp of smoke emanates[end if][if the Harvard Mark II is not working]. The computer lies dormant[end if]."
The desk is a supporter in the the east lab.
Rule for writing a paragraph about the desk: say "A metal desk sits against the southern wall[if something is on the desk]. On the desk [is-are a list of things on the desk][end if]."
Instead of examining the desk when something is on the desk:
say "Since there are no drawers, it's actually more of a solid, metal table. On the desk [is-are a list of things on the desk]."
The logbook is on the desk. The description of the logbook is "A plethora of notes. The last two entries are:[paragraph break] 1100 - Started Cosine Tape (Sine check)[paragraph break] 1525 - Started Multi+Adder Test."
[Now we create the Harvard Mark II and its relay panels. It has two states: working or, if the moth has flown or crawled into the relay panels, not working.]
The Harvard Mark II is a backdrop. It can be working. It is working. It is in the east lab and the west lab. Understand "switches", "computer", "dials", and "array" as the Harvard Mark II.
The description of the Harvard Mark II is "A marvel of modern computing! Its width spans all 55 feet of the lab's northern wall, and it towers over the tallest of men. With its 3000 decimal storage reels, 1400 rotary dial switches, and 500 miles of wire... this computer only takes a few seconds to perform a single multiplication operation![status]".
To say status:
if the Harvard Mark II is not working begin;
say "[line break]Unfortunately, the 5 tons of computational machinery appears to have shut down[if the player is in the west lab and the dead moth is on the relay panels], possibly as a result of whatever is causing the wisp of smoke to emanate from the relay panels[end if].";
The relay panels are scenery. They are a supporter. The relay panels are in the west lab. "It's these electromagnetic relays that make the Harvard Mark II a 'relay computer' and so much faster than its mechanical predecessor, the Mark I[if the dead moth is on the relay panels]. The unfortunate remains of an errant moth smolder on one the relays (relay 70, panel F, to be precise)[end if]."
Instead of putting something on the relay panels:
say "Sticking something in the relay panels would inevitably cause a glitch in the system."
[Here we define the moth.]
The moth is an animal. The moth can be flying. The moth is either living or dead. The moth is living. The moth is in the west lab. "[if the moth is flying]A moth flutters about the lab[otherwise]A moth is crawling over the switches and panels of the computer[end if]."
The description of the moth is "[if the moth is living]It's small, soft, and white... and very curious about all the lights.[otherwise]Burnt to a crisp.[end if]"
Rule for printing the name of the dead moth:
say "poor moth, burnt to a crisp".
Instead of taking the living moth:
say "It flits out of your reach.";
if the moth is not flying, now the moth is flying.
Instead of taking the dead moth:
say "You pick up the poor, burnt moth.";
move the moth to the player.
[The mother either crawls along the computer, or flits about the room. If it's flying, there's a one in three chance that the moth will land on the computer.]
Every turn when the living moth is flying:
if the moth is being debugged, say "// Rolling the dice for the flying moth...";
if a random chance of 1 in 3 succeeds begin;
now the moth is not flying;
if the player can see the moth, say "The moth settles among the switches of the computer.";
if the moth is being debugged, say "// The moth is no longer flying.";
[Once it's landed, there's a chance it'll crawl into the relay panels and fry itself and the computer. ]
Every turn when the living moth is not flying:
if the moth is being debugged, say "// Rolling the dice for the crawling moth...";
if a random chance of 1 in 3 succeeds, fry the moth.
To fry the moth:
if the moth is being debugged, say "// The moth has crawled into the relay panels.";
now the moth is dead;
now the moth is on the relay panels;
now the Harvard Mark II is not working;
if the player can see the moth begin;
say "The moth disappears among the relay panels. A moment later a sharp electrical crack, followed by a wisp of smoke, emanates from within the computer. A moment after that, the computer shuts down.";
say "A distant, electrical pop preludes the sudden shutdown of the computer.";
[To win the game, the player must tape the moth to the logbook. We'll first create the tape and tape dispenser.]
The plural of piece of tape is pieces of tape. A piece of tape is a kind of thing.
The tape dispenser is a container on the desk. In the tape dispenser are five pieces of tape.
Instead of examining the tape dispenser:
if the tape dispenser is being debugged, say "// There are now [number of pieces of tape in the tape dispenser] pieces of tape in the dispenser.";
if the tape dispenser contains exactly one piece of tape begin;
say "It appears there is only enough tape for you to take one more piece.";
otherwise if the tape dispenser contains at least two pieces of tape;
say "It contains a roll of tape.";
say "The dispenser is empty.";
Instead of taking a piece of tape when the noun is in the tape dispenser:
say "You rip a piece of tape off the dispenser.";
move the noun to the player;
if the tape dispenser is being debugged, say "// There are now [number of pieces of tape in the tape dispenser] pieces of tape in the dispenser."
Instead of inserting something into the dispenser:
say "You can't put anything back into the dispenser."
[Finally, we create a verb that will enable the player to tape the bug to the logbook.]
Understand "tape [something] to [something]" as taping it to.
Taping it to is an action applying to one thing and one visible thing.
Check taping it to (this is the you need tape rule):
if the player is not carrying one piece of tape, say "You need to be carrying a piece of tape first." instead.
Check taping it to (this is the block taping rule):
say "There is no point in taping [the noun] to [the second noun]." instead.
Carry out taping it to (this is the successful taping rule):
let x be a random piece of tape which is carried by the player;
remove x from play;
Report taping it to:
say "Successful taping!"
Instead of taping the dead moth to the logbook:
abide by the you need tape rule;
say "You tape the moth to the logbook, and annotate it with 'First actual case of bug being found.'";
end the game saying "You have made history"
[Instead of inserting the dead moth into the logbook:
try taping the dead moth to the logbook;
Test me with "w/take moth/x moth/x panels/take moth/e/x logbook/take piece of tape/tape moth to logbook".