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 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]".