The Amazing Interactive Turing Machine

An interactive fiction by J.D. Clemens (2006) - the Inform 7 source text

Home page

Contents
Previous
Next

Complete text
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."