Cubes — 1 of 1

Daniel M. Stelzer

Release 1

"Cubes" by "Daniel M. Stelzer"

Release along with the source text, an interpreter, and a "StatCounter" website.

The story headline is "An Interactive Experiment"

Include Serial And Fix by Andrew Plotkin.

Use American dialect and the serial comma.

[In the game Spellbreaker by Brian Moriarty, there's a standard twelve-coins puzzle. You have twelve cubes labelled x1 through x12. One is real, the eleven others are fakes, and the only way to escape the Vault is to find the real one. You also have a spell to detect magic, but it can only be used three times, and you don't know whether the real cube is more or less magical than the rest.

There is an especially devious twist to implementation of the puzzle in that game, though: luck will never be on your side. There is no one 'real' cube; the real cube is decided at the end, when you try to use it. If there's still any ambiguity at all, any other possibility which would be consistent with the results the player saw, that possibility will be chosen instead. So you'll only have the correct cube if you have actually eliminated every other alternative.

This is a sample implementation of that puzzle in Inform 7.]

The Outer Vault is a room. "You are in a large, bare concrete room. There are two piles on the floor.[paragraph break]The first contains [the list of things on the first pile].[line break]The second contains [the list of things on the second pile]."

A pile is a kind of supporter. A pile is scenery. The first pile is a pile in the Outer Vault. The second pile is a pile in the Outer Vault.

Instead of inserting something into a pile: try putting the noun on the second noun.

Understand "pile" as a pile. Understand "piles" as the plural of a pile.

A cube is a kind of thing. The x1 cube, the x2 cube, the x3 cube, the x4 cube, the x5 cube, and the x6 cube are cubes on the first pile. The x7 cube, the x8 cube, the x9 cube, the x10 cube, the x11 cube, and the x12 cube are cubes on the second pile. The indefinite article of a cube is "the".

A cube can be potentially stronger. A cube is usually potentially stronger.

A cube can be potentially weaker. A cube is usually potentially weaker.

Definition: a cube is eligible rather than ineligible:

if it is potentially stronger, yes;

if it is potentially weaker, yes;

no.

The currently selected cube is a cube that varies. The currently selected strength is a truth state that varies.

Understand "cube" as a cube. Understand "cubes" as the plural of a cube.

Definition: a cube is non-stacked rather than stacked:

if it is on a pile, no;

yes.

Instead of putting something on a stacked cube: try putting the noun on the holder of the second noun.

Instead of putting something on a non-stacked cube: say "That sounds like you're trying to create a stack, and the stacking of cubes into more than two piles is expressly forbidden under Hexahedral Edict #472." [There's no real reason to forbid cube-stacking except that it would break the puzzle. In Spellbreaker it's just met with a generic refusal.]

To decide which pile is the counterpart of (stack - a pile):

if the stack is the first pile, decide on the second pile;

decide on the first pile.

[A pile has an object called the counterpart. [Workaround for Bug #1228 if you're using 6L02 - comment out the phrase above and uncomment this section.]

The counterpart of the first pile is the second pile.

The counterpart of the second pile is the first pile.]

Casting jindak is an action applying to nothing. Understand "jindak" as casting jindak.

Carry out casting jindak: follow the cube selection rules.

Instead of casting jindak for the fourth time: say "Your time is up. Make your choice!"

The cube selection rules are a rulebook. [This rulebook figures which cubes are still viable possibilities and which are not, and updates the list accordingly.]

First cube selection rule: [This first selects a random possible cube and a random possible strength, hypothetically. Then we're going to figure out what other situations are still consistent with that information. Then we tell the player what they learned.]

now the currently selected cube is a random eligible cube;

if the currently selected cube is potentially stronger:

if the currently selected cube is potentially weaker:

now the currently selected strength is a random truth state; [If it could be either stronger or weaker, pick one at random.]

otherwise:

now the currently selected strength is true; [True means it's stronger than the fake cubes.]

otherwise:

now the currently selected strength is false. [False means it's weaker.]

A cube selection rule: [If one pile has more cubes, that one glows more brightly regardless of which is real.]

let X be the number of cubes on the first pile;

let Y be the number of cubes on the second pile;

if X is Y, make no decision;

say "The [if X is greater than Y]first[else]second[end if] pile glows more brightly, probably because it contains more cubes.";

rule succeeds.

A cube selection rule when the currently selected strength is true: [If the scenario we're envisioning has this cube being stronger, what other possibilities would still be viable?]

if the currently selected cube is on a pile (called the stack):

now every cube on the stack is not potentially weaker; [If this stack is glowing more brightly, the cubes here can't be weaker than the fake cubes.]

let the other stack be the counterpart of the stack;

now every cube on the other stack is not potentially stronger; [Similarly, the cubes on the other stack can't be stronger.]

now every non-stacked cube is not potentially weaker; [And cubes not on the stacks can't be either.]

now every non-stacked cube is not potentially stronger.

A cube selection rule when the currently selected strength is false: [Same for if the scenario has it being weaker.]

if the currently selected cube is on a pile (called the stack):

now every cube on the stack is not potentially stronger;

let the other stack be the counterpart of the stack;

now every cube on the other stack is not potentially weaker;

now every non-stacked cube is not potentially stronger;

now every non-stacked cube is not potentially weaker.

A cube selection rule when the currently selected cube is non-stacked: [If the cube we're using as our hypothetical choice isn't on a stack at all, then neither stack is brighter, so none of those cubes can be the real one.]

repeat with the box running through stacked cubes:

now the box is not potentially stronger;

now the box is not potentially weaker.

Last cube selection rule: [Now tell the player what information they get.]

if the currently selected cube is non-stacked:

say "Both piles seem to glow with identical brightness.";

otherwise:

let the stack be the holder of the currently selected cube;

if the currently selected strength is false, let the stack be the counterpart of the stack; [If the real cube is weaker in this scenario, we want to indicate the opposite pile.]

say "Both piles of cubes glow with a faint blue glow. However, [the stack] is glowing more brightly.".

Requesting debug information is an action applying to nothing. Understand "girgol" as requesting debug information. [This is a little convenience so we can see how everything is working. It lists all potentially real cubes and says whether they might be stronger or weaker than the fakes,]

Carry out requesting debug information:

say "[bracket]DEBUG INFORMATION:[close bracket][line break]";

repeat with the box running through eligible cubes:

say "[Box]: [if the box is potentially stronger]S[end if] [if the box is potentially weaker]W[end if][line break]".

Casting blorple at is an action applying to one thing. understand "blorple [something]" as casting blorple at.

Carry out casting blorple at something:

if the noun is not a cube:

say "[The noun], not being a Cube of Foundation, fails to teleport you from the Vault.";

end the story saying "You have failed";

if the noun is ineligible:

say "[The noun] is not even close to being the correct cube.";

end the story saying "You have failed";

repeat with the item running through cubes:

if the item is not the noun and the item is eligible:

say "[The noun] could have been the correct cube...but it wasn't.";

end the story saying "You have failed";

stop the action;

say "[The noun] is [if the noun is potentially stronger]more[else]less[end if] powerful than any other cube.";

end the story finally saying "You have succeeded".