Counterfeit Monkey — 206 of 292

Emily Short

Release 6

Chapter 6 - The Turntable

[The turntable is a supporter. It is scenery. The carrying capacity is 1. The description is "A swiftly rotating platform able to go clockwise or anticlockwise. It is currently set to [rotation-direction]." Understand "table" or "turn table" as the turntable.

Rotation-direction is a kind of value. The rotation-directions are clockwise and anticlockwise. Understand "counterclockwise" and "widdershins" as anticlockwise. The turntable has a rotation-direction.

Understand "set [turntable] to [rotation-direction]" as setting it to the direction. Setting it to the direction is an action applying to one thing and one rotation-direction.

Instead of vaguely setting the turntable:

if the turntable is clockwise, try setting turntable to the direction anticlockwise; otherwise try setting the turntable to the direction clockwise.

Carry out setting it to the direction:

now the rotation-direction of the turntable is the rotation-direction understood.

Report setting it to the direction:

say "[The turntable] now goes [the rotation-direction of the turntable]."

Every turn when the turntable is visible and something is on the turntable:

if not looking:

follow the turntable-turning rule;

say paragraph break.

This is the turntable-turning rule:

let the chosen article be a random thing on the turntable;

let X be the chosen article;

let the goal text be indexed text;

let goal text be "[printed name of the X]";

if the turntable is clockwise

begin; [put first letter at the end, as in ape --> pea]

if the goal text matches the regular expression "(.)(.*)", replace the regular expression "(.)(.*)" in goal text with "\2\1";

otherwise; [put last letter at the front, as in arc --> car]

if the goal text matches the regular expression "(.*)(.)", replace the regular expression "(.*)(.)" in goal text with "\2\1";

end if;

repeat with item running through things in the repository

begin;

if the goal text exactly matches the regular expression "[item]", now the chosen article is the item;

end repeat;

if the chosen article is not X

begin;

now the chosen article is not proffered by anything;

now everything which proffers X proffers the chosen article;

now everything which is on the turntable is in the repository;

move the chosen article to the turntable;

say "[if looking]After the turntable does its work,[otherwise]The turntable whirls faster than we can follow, and when it is done[end if] there [is-are a list of things on the turntable]. ";

otherwise;

if looking

begin;

if exactly one thing is on the turntable, say "It does";

otherwise say "[The list of things on the turntable] do[es]";

say " not change, however. ";

otherwise;

say "The turntable spins for a moment, [one of]then dies down again[or]without effect[or]without changing [the list of things on the turntable][at random]. ";

end if;

end if.

Rule for disclosing exterior of something (called special-target) which is on the turntable:

say "[The special-target] [is-are] spinning rapidly [rotation-direction of the turntable] on [a turntable][if a thing is on the turntable], together with [a list of mentionable things which are on the turntable][end if]. [run paragraph on]";

follow the turntable-turning rule.

Rule for disclosing contents of the turntable (this is the turntable-content rule):

say "On [the turntable], [a list of things on the turntable] spin[s] [rotation-direction of the turntable]. [run paragraph on]";

follow the turntable-turning rule. ]