Skip to content

Instantly share code, notes, and snippets.

@koo5
Created November 22, 2012 02:59
Show Gist options
  • Save koo5/4129213 to your computer and use it in GitHub Desktop.
Save koo5/4129213 to your computer and use it in GitHub Desktop.
"The Amazing Interactive Turing Machine" by "J.D. Clemens"
"The Amazing Interactive Turing Machine" by "J.D. Clemens"
Section 1 - Bibliographic Data
The story headline is "An Interactive Waste of Time".
The story genre is "Other".
The story description is "You have almost reached the end of your shift. All that remains is to clean one final room, the control room for that weird contraption being built by the scientists here. Carrying your usual equipment, you open the door and step into... The Amazing Interactive Turing Machine!"
Release along with source text and a website.
Use the serial comma, American dialect, no scoring, and full-length room descriptions.
Include Locksmith by Emily Short.
Include Basic Screen Effects by Emily Short.
After printing the banner text, say "Type 'about' for information."
Section 2 - Setup
The time of day is 11:45 PM.
When play begins:
adjust the dials;
clear the tape;
change the right hand status line to "[time of day]";
say "You have almost reached the end of your shift. All that remains is to clean one final room, the control room for that weird contraption being built by the scientists here. [paragraph break]Carrying your usual equipment, you open the door and step into...".
Asking for information is an action out of world. Understand "about" or "help" as asking for information.
Report asking for information:
say "'Why?' you might ask. [paragraph break]Good question. This was written as a break from an actual project I was working on (which is itself a break from what I really should be doing) and as practice with Inform 7. It was written sporadically over two days in May 2006 and has not been beta-tested, so it is probably less than perfect. But it seems to work.[paragraph break]And if anyone ever asks you if Inform 7 is Turing Complete, well, here you are.[paragraph break]Thanks go to Graham Nelson, Emily Short, Andrew Hunter, David Kinder, and everyone else involved with the creation of Inform 7, and to everyone who has answered my questions on raif.[paragraph break]Currently, the game(?) and source code are available at www.math.psu.edu/clemens/IF/Turing, and you can email me at jdc20@psu.edu.[paragraph break]Enjoy.[paragraph break]-JDC[paragraph break]".
[FINISH]
Section 3 - States
The current state is a number that varies. The current state is 1.
The head position is a number that varies. the head position is 1.
The previous state is a number that varies. The previous state is 1.
Table of State Transitions
StateN E State Z State Z Action O State O Action
1 1 2 write one 1 move right
2 2 3 move left 2 move right
3 3 3 halt 4 write zero
4 4 4 move left 5 write zero
5 6 5 move left 5 move left
6 6 6 halt 6 halt
with 44 blank rows
A machine action is a kind of value. The machine actions are move left, move right, write zero, write one, and halt.
Section 4 - Control Room
A button is a kind of thing.
The Control Room is a room. "[if unvisited]This is the control room of the Amazing Interactive Turing Machine. [end if]A trapdoor in the floor leads into the bowels of the machine. [if unvisited]A small grimy window looks out onto a tattered paper tape, and a set of instructions are tacked onto wall. The exit is to the west[otherwise]The window looks out onto the tape[end if]. A cluttered control panel leans against the wall."
Instead of exiting when the player is in the control room, try going west instead.
Instead of going west in the control room when the machine is not used, say "Why not have some fun before leaving?"
Instead of going west in the control room when the floor is dirty, say "You need to clean the floor here before leaving."
Instead of going west in the control room: say "The odd contraption has worn you out, and it is time to go home.";
end the game saying "You have left the Amazing Interactive Turing Machine".
The set of instructions are scenery in the control room.
Instead of examining the instructions:
say "[bold type]Instructions for using the Amazing Interactive Turing Machine[roman type][paragraph break]Running the machine:[line break]- To start: Press the green button. [line break]- To pause, or run a single step: Press the yellow button. [line break]- To reset the machine: Press the red button. [line break]- To clear all state information: Press the tiny recessed button. [line break]('run', 'step', 'reset', and 'clear' also work) [line break][paragraph break]Using the state controller:[line break]- To select a state for editing: Set the selected state dial to the desired number. [line break]- To erase the selected state: Press the erase button. [line break]- To change a state transition (E, Z, or O): set the corresponding dial to the desired number. [line break]- To change a machine action (Z or O): set the corresponding dial to the desired action.[paragraph break]To set the tape: 'set tape to 1 1 0 1' will set the tape to *1101 (note that only the digits 0 and 1 may be used, and they must be separated by spaces).[paragraph break]";
say "How the machine works:[line break]The left edge of the tape is marked with a *; all other cells can contain either 0 or 1 (a blank cell is treated as 0). The machine has a read/write head, which initially starts in state 1 at the first cell to the right of *. Our machine head has been fitted with a red window to highlight the cell being read (apologies to colorblind users). To perform one step, the machine consults the state table for the current symbol (*, 0, or 1, denoted E, Z, or O on the controls). It changes to the corresponding state entry and performs the corresponding action. The possible actions are: move left, move right, write zero, write one, and halt. When reading *, the only possible action is to move right. The machine runs until it reaches a halt instruction, or enters a state without a state entry.[paragraph break]Due to funding restrictions, our machine currently has only [number of rows in the Table of State Transitions] states and a tape length of [number of rows in the Table of Tape Values].[paragraph break]At the bottom, someone has scrawled 'Yes! We finally have the unary adder working!'[line break]".
Instead of taking the instructions, say "The tack is surprisingly difficult to remove."
The window is scenery in the control room. Instead of searching or examining the window, try examining the tape.
The trapdoor is a scenery door. It is below the Control Room and above the Bowels of the Machine. Understand "trap" or "door" as the trapdoor.
Before going down from the control room when the machine is active, say "It doesn't seem wise to climb down there while the machine is running." instead.
Before going down from the control room, say "You lower yourself into the machine..."
Before going up from the bowels, say "You pull yourself back up."
Section 5 - Control Panel
The control panel is scenery in the control room. The description is "The panel contains [list of nonbutton things which are part of the panel] and various buttons: [list of buttons which are part of the panel]."
The display screen is part of the control panel.
Instead of examining the display screen:
say "The display screen shows the following information:[line break][line break][fixed letter spacing]State T* T0 Action 0 T1 Action 1[line break]-------------------------------------------[line break]";
repeat with N running from 1 to the number of rows in the Table of State Transitions begin;
if there is a StateN of N in the Table of State Transitions begin;
print line N;
end if;
end repeat;
say "[variable letter spacing][line break]".
To print line (N - a number):
choose row with a StateN of N in the Table of State Transitions;
say " [justified StateN entry]: [justified E State entry] [justified Z State entry] [justified Z Action entry] [justified O State entry] [justified O Action entry][line break]".
To say justified (x - a number): if x < 10, say " "; say "[x]".
To say justified (m - a machine action):
say "[m]";
if m is move left, say " ";
if m is move right, do nothing;
if m is write zero, do nothing;
if m is write one, say " ";
if m is halt, say " ".
An SDial is a kind of thing. An SDial has a number called setting. The setting of an SDial is usually 1. Instead of examining an SDial, say "[The noun] is currently set to [setting of noun]."
An ADial is a kind of thing. An ADial has a machine action called action. The action of an ADial is usually halt. Instead of examining an ADial, say "[The noun] is currently set to: [action of noun]."
Understand "set [SDial] to [number]" as setting the state of it to. Setting the state of it to is an action applying to one thing and one number. Understand "turn [SDial] to [number]" as setting the state of it to.
Understand "set [ADial] to [machine action]" as setting the action of it to. Setting the action of it to is an action applying to one thing and one machine action. Understand "turn [ADial] to [machine action]" as setting the action of it to.
Check setting the state of it to:
if the number understood < 1, say "The lowest state is state 1." instead;
if the number understood > the number of rows in the Table of State Transitions, say "Sorry, the machine can only handle states up to [the number of rows in the Table of State Transitions]." instead.
Carry out setting the state of it to:
change the setting of the noun to the number understood;
After setting the state of the selected state dial to:
adjust the dials; continue the action.
After setting the state of the E state dial to:
choose row with a StateN of the setting of the selected state dial in the Table of State Transitions;
change E State entry to the number understood;
continue the action.
After setting the state of the Z state dial to:
choose row with a StateN of the setting of the selected state dial in the Table of State Transitions;
change Z State entry to the number understood;
continue the action.
After setting the state of the O state dial to:
choose row with a StateN of the setting of the selected state dial in the Table of State Transitions;
change O State entry to the number understood;
continue the action.
Report setting the state of it to:
say "The controller readout now shows: [line break]";
print the readout.
To print the readout:
say "[fixed letter spacing]State T* T0 Action 0 T1 Action 1[line break]-------------------------------------------[line break]";
print line setting of state dial;
say "[variable letter spacing][line break]".
Carry out setting the action of it to:
change the action of the noun to the machine action understood.
After setting the action of the Z action dial to:
choose row with a StateN of the setting of the selected state dial in the Table of State Transitions;
change Z Action entry to the machine action understood;
continue the action.
After setting the action of the O action dial to:
choose row with a StateN of the setting of the selected state dial in the Table of State Transitions;
change O Action entry to the machine action understood;
continue the action.
Report setting the action of it to:
say "The controller readout now shows: [line break]";
print the readout.
The state controller is part of the panel.
Instead of examining the state controller:
say "The controller is for editing machine states and contains [a list of things which are part of the controller]. A readout shows the state set for editing: [line break]";
print the readout.
The selected state dial, the E state dial, the Z state dial, and the O state dial are SDials which are part of the state controller.
The Z Action dial and the O action dial are ADials which are part of the state controller.
The erase button is part of the state controller. The description is "The erase button erases the currently selected state."
Instead of pushing the erase button:
let edit state be the setting of the state dial;
if there is a StateN of the edit state in the Table of State Transitions begin;
choose row with a StateN of the edit state in the Table of State Transitions;
blank out the whole row;
end if;
if edit state is 1 begin;
say "You return the initial state 1 to its defaults.";
otherwise;
change the setting of the state dial to 1;
say "You clear state [edit state] and the state dial reverts to state 1.";
end if;
adjust the dials.
To adjust the dials:
let edit state be the setting of the selected state dial;
if there is a StateN of the edit state in the Table of State Transitions begin;
choose row with a StateN of the edit state in the Table of State Transitions;
change the setting of the E state dial to the E State entry;
change the setting of the Z state dial to the Z State entry;
change the setting of the O state dial to the O State entry;
change the action of the Z action dial to the Z Action entry;
change the action of the O action dial to the O Action entry;
otherwise;
choose a blank row in the Table of State Transitions;
change the StateN entry to the edit state;
change the E State entry to 1;
change the Z State entry to 1;
change the O State entry to 1;
change the Z Action entry to halt;
change the O Action entry to halt;
change the setting of the E state dial to 1;
change the setting of the Z state dial to 1;
change the setting of the O state dial to 1;
change the action of the Z action dial to halt;
change the action of the O action dial to halt;
end if.
The green button, the yellow button, the red button, and the tiny recessed button are buttons.
Definition: a thing is nonbutton if it is not a button.
The green button is part of the panel. The description is "The green button is labeled 'Go'." Instead of pushing the green button, try running.
The yellow button is part of the panel. The description is "The yellow button is labeled 'Pause/Step'." Instead of pushing the yellow button, try stepping.
The red button is part of the panel. The description is "The red button is labeled 'Reset'." Instead of pushing the red button, try resetting.
The tiny recessed button is part of the panel. The description is "The tiny recessed button is labeled 'Clear All'." Instead of pushing the tiny recessed button, try clearing.
The Turing Machine is a backdrop. It is everywhere.
Instead of examining the Turing Machine, say "The machine is all around you."
The machine is either active, paused, or stopped. The machine is paused.
The machine is either used or unused. The machine is unused.
The head is scenery in the control room. "The machine head is currently in state [current state]."
Understand "machine head" as the head.
Before examining the head for the first time, say "The machine head uses a set of rollers to feed the tape. A square of red cellophane highlights the tape square being read (possibly an intentional pun by the designers). [run paragraph on]".
Section 6 - Bowels of the Machine
The Bowels of the Machine is a dark room. "[If unvisited]The insides of the Amazing Interactive Turing Machine are cramped and covered with grease. There is an orange button set into the wall. Above the button is stenciled 'Do not press the orange button'. [otherwise]Set into the wall is [a orange button]. [end if]Scrawled in chalk you see: 'State [current state]', and a tiny window shows a [current cell]. The trapdoor leads back up and various small holes are cut into the wall[holes][state actions]."
To say current cell:
if head position is 0, say "*";
otherwise say "[the Symbol in row head position of the Table of Tape Values]".
To say holes:
if there is a StateN of the current state in the Table of State Transitions begin;
let count be 0;
choose row with a StateN of the current state in the Table of State Transitions;
if the E State entry is not the current state begin;
increase count by 1;
say "; one of them is labeled '*: to [E State entry]'";
end if;
if the Z State entry is not the current state begin;
if count is 0, say "; one of them";
otherwise say ", another";
say " is labeled '0: to [Z State entry]'";
increase count by 1;
end if;
if the O State entry is not the current state begin;
if count is 0, say "; one of them";
if count is 1, say ", another";
if count is 2, say ", a third";
say " is labeled '1: to [O State entry]'";
end if;
end if.
To say state actions:
if there is a StateN of the current state in the Table of State Transitions begin;
choose row with a StateN of the current state in the Table of State Transitions;
say ". On the ceiling you see etched: '0: [Z Action entry], 1: [O Action entry]'";
end if.
The hole is scenery in the bowels. Understand "holes" as the hole. The description is "The holes are much to small to see through, let alone fit through."
Instead of doing anything other than examining the hole, try examining the hole.
The orange button is a scenery button in the bowels. The description is "Above the button is stenciled: 'Do not press the orange button.'".
The orange button is either used or unused. It is unused.
Rule for printing the name of the orange button when the orange button is unused: say "tempting orange button".
Before pushing the orange button for the first time, say "Predictable. Unfortunately, you have just blown up the machine. [paragraph break]Just kidding.[paragraph break]".
Instead of pushing the orange button, try inside stepping.
Instead of stepping when the player is in the bowels, try inside stepping.
Inside stepping is an action applying to nothing.
Before inside stepping: now the orange button is used.
Check inside stepping: if the machine is stopped, say "Nothing happens. Perhaps the machine has halted." instead.
Check inside stepping:
if there is a StateN of the current state in the Table of State Transitions, continue the action;
say "Nothing happens. Perhaps the machine has halted." instead.
Carry out inside stepping:
carry out the single stepping activity.
Report inside stepping: say "You press the button and the machine shakes horribly. [if the current state is not the previous state]Your body is twisted horribly, and you find yourself in a new space labeled 'State [current state]'. [end if]The window now shows a [current cell]."
Section 7 - The Tape
The tape is a backdrop. It is everywhere. The description is "The tape currently shows: [tape contents]."
Instead of examining the tape when the player is in the bowels, say "You can only see one cell at a time from here."
Before examining the tape for the first time, say "The tape is old and yellowed, probably military surplus, and frayed from rough edges on the machine head. A square of red cellophane in the machine head highlights one of the tape squares. [run paragraph on]".
To say tape contents:
say "[fixed letter spacing]";
let table end be the head position;
repeat with N running from table end to the number of rows in the Table of Tape Values begin;
choose row N in the Table of Tape Values;
if there is a Symbol entry begin;
if the Symbol entry is 1, change table end to N;
end if;
end repeat;
let zeros be the number of rows in the Table of Tape Values - table end;
repeat with N running from 0 to the table end begin;
if the head position is N, say "[bold type][red letters]";
if N is 0 begin;
say "*";
otherwise;
choose row N in the Table of Tape Values;
if there is a Symbol entry, say "[Symbol entry]";
otherwise say "0";
end if;
say "[default letters][roman type]";
end repeat;
say "[variable letter spacing]"
After reading a command:
if the player's command includes "set tape to" or the player's command includes "set the tape to" begin;
repeat with N running from 1 to the number of rows in the Table of Tape Values begin;
choose row N in the Table of Tape Values;
if the player's command includes "[number]" begin;
if the number understood > 1 begin;
say "The tape can contain only 0 and 1.";
reject the player's command;
end if;
change the Temp entry to the number understood;
cut the matched text;
otherwise;
change the Temp entry to 0;
end if;
end repeat;
end if.
Instead of setting the tape to when the player is in the bowels, say "You need to set the tape in the control room."
Instead of setting the tape to:
repeat through the Table of Tape Values begin;
change the Symbol entry to Temp entry;
end repeat;
say "You set the tape to: [tape contents]."
To clear the tape:
repeat with N running from 1 to the number of rows in the Table of Tape Values begin;
choose row N in the Table of Tape Values;
change the Symbol entry to 0;
end repeat.
Table of Tape Values
Symbol Temp
a number a number
with 511 blank rows
Section 8 - Stepping
Stepping is an action applying to nothing. Understand "step" as stepping.
Instead of stepping when the machine is active:
now the machine is paused;
say "You press the yellow button and the machine pauses."
Check stepping: if the machine is stopped, say "The machine has halted. You will need to reset it before running it again." instead.
Check stepping:
if there is a StateN of the current state in the Table of State Transitions, continue the action;
say "The machine has halted." instead.
Carry out stepping:
carry out the single stepping activity.
Report stepping: say "You press the button and the machine grinds [if the current state is the previous state]along[otherwise]into state [current state][end if]. The tape shows: [tape contents]."
Single stepping is an activity.
The last for single stepping rule:
change previous state to current state;
if head position > 0, let bit be Symbol in row head position of the Table of Tape Values;
choose row with a StateN of current state in the Table of State Transitions;
if head position is 0 begin;
change the current state to the E State entry;
change the head position to 1;
otherwise;
let new state be the Z State entry;
let new action be the Z Action entry;
if bit is 1 begin;
let new state be the O State entry;
let new action be the O Action entry;
end if;
change the current state to the new state;
if the new action is move left, decrease the head position by 1;
if the new action is move right, increase the head position by 1;
if the head position > the number of rows in the Table of Tape Values begin;
decrease the head position by 1;
now the machine is stopped;
say "There is a terrible wrenching sound as the machine tries to run off the end of the tape and grinds to a halt.";
end if;
if the new action is write zero, change the Symbol in row head position of the Table of Tape Values to 0;
if the new action is write one, change the Symbol in row head position of the Table of Tape Values to 1;
if the new action is halt, now the machine is stopped;
end if;
if there is a StateN of current state in the Table of State Transitions, do nothing;
otherwise now the machine is stopped;
now the machine is used.
Section 9 - Running, Resetting, Clearing
Running is an action applying to nothing.
Understand the command "run" as something new. Understand "run" as running when the player is in the control room.
Instead of running when the machine is stopped, say "The machine has halted. You will need to reset it before running it again."
Instead of running when the machine is active, say "The machine is already running."
Carry out running: now the machine is active.
Report running: say "You press the green button and the machine slowly creaks to life."
Every turn when the machine is active:
carry out the single stepping activity;
if the machine is stopped, say "The machine comes to a halt in state [current state]. [run paragraph on]";
otherwise say "The machine churns [if the current state is the previous state]along[otherwise]into state [current state][end if]. [run paragraph on]";
say "The tape shows: [tape contents]."
Resetting is an action applying to nothing. Understand "reset" as resetting when the player is in the control room.
Carry out resetting:
now the machine is paused;
change the head position to 1;
change the current state to 1;
clear the tape.
Report resetting:: say "You press the red button[if the machine was active] and the machine winds to a halt[end if]. The head returns to its starting position, clearing the tape as it goes."
Clearing is an action applying to nothing. Understand "clear" as clearing when the player is in the control room.
Instead of clearing for the first time: say "You hesitate a moment, unsure of whether this is safe."
Check clearing when the machine is active: say "This doesn't seem safe while the machine is running." instead.
Carry out clearing:
silently try resetting;
repeat through the Table of State Transitions begin;
blank out the whole row;
end repeat;
change the setting of the selected state dial to 1;
adjust the dials.
Report clearing: say "You press the tiny button, feeling a slight twinge of uneasiness as you do so. The machine writhes in pain and all of the display screens clear."
Section 10 - The Player
The description of yourself is "You are tired after a long shift, and your coveralls look even worse than you do."
The player carries a mop. The description of the mop is "So old that it is basically useless."
Instead of dropping the mop, say "No, you don't want to forget your mop when you leave."
Understand the command "mop" as "clean".
The floor is a backdrop. It is everywhere.
The floor is either dirty or clean. The floor is dirty.
Instead of rubbing the floor when the player is in the control room for the third time:
say "You finally manage to get the floor clean, or at least cleaner than the rest of the room.";
now the floor is clean.
Instead of rubbing the floor when the player is in the bowels, say "This isn't part of your job."
Instead of rubbing the clean floor, say "It's not going to get any cleaner."
Instead of rubbing the floor, say "You mop for a while, but the floor is still pretty dirty."
The player carries a device called a flashlight. The description of the flashlight is "Old but reasonably functional."
Carry out switching on the flashlight: now the flashlight is lit.
Carry out switching off the flashlight: now the flashlight is not lit.
Instead of dropping the flashlight when in darkness, say "No, you'll never find it again."
Before switching on the flashlight: if the flashlight is not carried, silently try taking the flashlight.
Before switching off the flashlight: if the flashlight is not carried, silently try taking the flashlight.
Section 11 - Waiting
Waiting more is an action applying to one number. Understand "wait [number] minutes/turns" or "wait [number]" as waiting more.
Carry out waiting more:
Say "You settle in.";
let duration be the number understood - 1;
repeat with X running from 1 to duration begin;
follow the turn sequence rules;
end repeat.
Check waiting more: if the number understood > 59, say "You really haven't got that kind of patience." instead.
Before waiting for the third time, say "(You can also 'wait 3 minutes', e.g.) ".
[http://web.archive.org/web/20110612182843/http://www.math.psu.edu/clemens/IF/Turing/source.txt]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment