Child's Play

An interactive fiction by Stephen Granade (2007) - the Inform 7 source text

Section 3 - Cruising

[When you're pulled up on some things, you can cruise along them -- slide along their length. Babies do this with couches and chairs and the like. We keep track of what you can cruise along using a table. It would be clever to use relations here, but we don't just relate one thing to another; we relate one thing to another via a direction.]

Table of Cruising Possibilities
Primary   Direction   Reciprocal
north pink striped loveseat   south   south pink striped loveseat
south pink striped loveseat   north   north pink striped loveseat
west grey couch   east   middle grey couch
middle grey couch   west   west grey couch
middle grey couch   east   east grey couch
east grey couch   west   middle grey couch

To decide if going (goal - a direction) while holding onto (support - a thing) involves cruising:
    if support is not suitable for cruising, decide no;
    repeat through the Table of Cruising Possibilities begin;
        if primary entry is support and direction entry is goal, decide yes;
    end repeat;
    decide no.

To decide what thing is the other end of (support - a thing) to the (goal - a direction):
    repeat through the Table of Cruising Possibilities begin;
        if primary entry is support and direction entry is goal, decide on reciprocal entry;
    end repeat;
    change hacky global item to the support;
    report bug "[The hacky global item] doesn't have that direction in the Table of Cruising Possibilities.";
    decide on support.

To decide what thing is the first end of (support - a thing) from the (goal - a direction):
    repeat through the Table of Cruising Possibilities begin;
        if reciprocal entry is support and direction entry is goal, decide on primary entry;
    end repeat;
    change hacky global item to the support;
    report bug "The reciprocal [hacky global item] doesn't have that direction in the Table of Cruising Possibilities.";
    decide on support.

To cruise (kid - a person) to (goal - direction) and hold (support - a thing):
    if kid is the player, say "You slide along while moving your hands to keep steady.";
    now the kid is pulled up on the support;
    change the last location of the kid to the location of the kid;
    move the kid to the room goal from the location of the kid;

The source code to Child's Play is licensed under a Creative Commons NonCommercial Sampling Plus 1.0 License.