The Amazing Interactive Turing MachineAn interactive fiction by J.D. Clemens (2006) - the Inform 7 source text | |
| Home page Contents Previous Next Complete text | 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. |