Suppose we have marbles that roll downhill across our map, in a life-size version of one of those marble-chute toys. We might now want to keep track of both compass relationships and which-room-slopes-into-which, so we make a new relation:
"Swerve left? Swerve right? Or think about it and die?"
Overlooking relates various rooms to various rooms.
The verb to overlook means the overlooking relation.
A thing can be spherical or lumpy. A marble is a kind of thing. A marble is always spherical. The player carries a marble called a red marble. The player carries a marble called an agate marble. The player carries a marble called a blue cloudy marble.
The Long Yellow Slide is north of the Funnel. The Long Yellow Slide overlooks the Blue Funnel. The Ski-jump is below the Blue Funnel. The Blue Funnel overlooks the Ski-jump. The Ski-jump overlooks the Landing Bowl. The Landing Bowl overlooks the Snake Run. The Landing Bowl is north of the Snake Run. The Snake Run overlooks the Goal. The Snake Run is north of the Goal.
Definition: a room is sloping if it overlooks a room.
And let's say we want the player to be allowed to slide, too, since that would be much more fun than just watching the marbles go:
Understand "sit" as sitting down. Sitting down is an action applying to nothing. Check sitting down: if the player is spherical, say "You are already seated." Carry out sitting down: now the player is spherical. Report sitting down: say "You sit, ready to slide wherever fate takes you."
Understand the command "stand" as something new.
Understand "stand" or "stand up" as standing up. Standing up is an action applying to nothing. Check standing up: if the player is lumpy, say "You are already standing." Carry out standing up: now the player is lumpy. Report standing up: say "You get to your feet."
Now a rule to control what happens to all our sliding and rolling objects:
Every turn:
repeat with item running through spherical things which are in sloping rooms:
let the current space be the holder of the item;
let the final space be a random room which is overlooked by the current space;
if the player can see the item and the item is a marble, say "[The item] rolls out of the room toward [the final space].[line break]";
if the player is the item, say "You keep sliding...";
move the item to the final space;
if the player can see the item and the item is a marble, say "[The item] rolls into the room from [the current space].[line break]".
Since the Ski-jump overlooks the Landing Bowl, the marble will be able to fly through the air to its destination, even though there is no map connection to allow the player to cross. We might want to let the player make it across this barrier also, so:
Instead of jumping in a sloping room:
say "You leap...";
move the player to a random room overlooked by the location.
Because overlooking is various-to-various, we could include that element popular in marble chute toys, the splitter:
The Downhill Splitter is north of the Long Yellow Slide. "The green plastic chute runs downhill towards a Y-junction, forcing incoming marbles right or left."
The Downhill Splitter overlooks the Long Yellow Slide and the Purple Snaking Passage. The Purple Snaking Passage is southeast of the Downhill Splitter. The Purple Snaking Passage overlooks the Landing Bowl. The Purple Snaking Passage is above the Landing Bowl.
The player is in the Downhill Splitter.
Test me with "drop red / drop blue / sit / z / stand up / drop agate / sit / z / z / z / z / z".
In the following, we pretend that every item has a cuboidal shape. Every thing has a length, width and depth, while a "measured container" also has interior dimensions. (Thus a 10x10x10 container with 1cm-thick sides might have interior dimensions 9x9x9.)
"Depth"
A length is a kind of value. 10 cm specifies a length. An area is a kind of value. 10 sq cm specifies an area. A length times a length specifies an area. A volume is a kind of value. 10 cu cm specifies a volume. A length times an area specifies a volume.
A thing has a length called height. A thing has a length called width. A thing has a length called depth. The height of a thing is usually 10 cm. The width of a thing is usually 10 cm. The depth of a thing is usually 10 cm.
To decide what volume is the exterior volume of (item - a thing):
let base area be the height of the item multiplied by the width of the item;
let base volume be the base area multiplied by the depth of the item;
decide on the base volume.
In order to see how these shapes might fit together spatially, we need to work out the three dimensions in order of size. (If we were only dealing with portable objects, we could simply insist that the length always be greater than the width which in turn must be greater than the depth, because we could always turn them over in our hands until this was so: but some of the things we deal with may be fixed in place.) A clever way to do this might be to put them in a table of three rows and sort it, but we will write the calculation out longhand:
To decide what length is the largest dimension of (item - a thing):
let long side be the height of item;
if the width of the item is greater than the long side, now the long side is the width of the item;
if the depth of the item is greater than the long side, now the long side is the depth of the item;
decide on the long side.
To decide what length is the middling dimension of (item - a thing):
let longer side be the height of item;
let shorter side be the width of item;
if the width of the item is greater than the height of the item:
let shorter side be the height of item;
let longer side be the width of item;
if the depth of the item is greater than the longer side, decide on the longer side;
if the depth of the item is less than the shorter side, decide on the shorter side;
decide on the depth of the item.
To decide what length is the shortest dimension of (item - a thing):
let short side be the height of item;
if the width of the item is less than the short side, now the short side is the width of the item;
if the depth of the item is less than the short side, now the short side is the depth of the item;
decide on the short side.
When testing this example, the author made use of the following: it's no longer needed, but may be useful to anyone else planning elaborations.
To test the dimensions of (item - a thing):
say "[the item] - height [height of the item], width [width of the item], depth [depth of the item].";
say "largest side [largest dimension of the item], middling [middling dimension of the item], smallest [shortest dimension of the item]."
We now introduce a new kind: a measured container, which not only has exterior dimensions - the height, width and depth which every thing now has - but also interior measurements. A convenient way to do calculations with the hollow interior is to regard it as if it were a solid shape in its own right, and we do this with the aid of something out of world, which the player never sees: the "imaginary cuboid", which is made into the shape of whatever measured container's interior is being thought about.
A measured container is a kind of container. A measured container has a length called interior height. A measured container has a length called interior width. A measured container has a length called interior depth.
There is an imaginary cuboid.
To imagine the interior of (receptacle - a measured container) as a cuboid:
now the height of the imaginary cuboid is the interior height of the receptacle;
now the width of the imaginary cuboid is the interior width of the receptacle;
now the depth of the imaginary cuboid is the interior depth of the receptacle.
To decide what volume is the interior volume of (receptacle - a measured container):
imagine the interior of the receptacle as a cuboid;
decide on the exterior volume of the imaginary cuboid.
If we assume that we could always pack items into a measured container with perfect ease, never wasting any space, then the only volume constraint will be that the total volume of the contents must not exceed the volume of the inside of the container. So we need to calculate the available volume.
To decide what volume is the available volume of (receptacle - a measured container):
let the remaining space be the interior volume of the receptacle;
repeat with item running through things in the receptacle:
decrease the remaining space by the exterior volume of the item;
if the remaining space is less than 0 cu cm, decide on 0 cu cm;
decide on the remaining space.
If we only constrained volume, a 140 cm-long fishing rod could fit into a 12 cm by 12 cm compact disc box. So we also insist the basic shape must fit, in some orientation perpendicular to one of the sides (i.e.: we can turn the item over in any of its three sides, but not turn it diagonally or wedge it in at a tilt). This requires the longest side of the item to be less than the longest side of the receptacle, and the middle-length side, and also the shortest side. The number of these conditions to fail gives us a clue as to how we can best describe the reason why the shape won't squeeze in.
Check inserting something (called the item) into a measured container (called the receptacle):
if the exterior volume of the item is greater than the interior volume of the receptacle, say "[The item] will never fit inside [the receptacle]." instead;
if the exterior volume of the item is greater than the available volume of the receptacle, say "[The item] will not fit into [the receptacle] with [the list of things in the receptacle]." instead;
imagine the interior of the receptacle as a cuboid;
if the largest dimension of the item is greater than the largest dimension of the imaginary cuboid, say "[The item] is too long to fit into [the receptacle]." instead;
if the middling dimension of the item is greater than the middling dimension of the imaginary cuboid, say "[The item] is too wide to fit into [the receptacle]." instead;
if the shortest dimension of the item is greater than the shortest dimension of the imaginary cuboid, say "[The item] is too bulky to fit into [the receptacle]." instead.
And finally a situation to try out these rules.
The Cubist Lab is a room. "A laboratory which, as the art critic Louis Vauxcelles said about Braque's paintings in 1908, is full of little cubes: everyday objects rendered as if cuboidal."
The box is a measured container. The interior height is 10 cm. The interior depth is 5 cm. The interior width is 6 cm. The player carries the box.
A pebble is a kind of thing. The height is usually 2 cm. The depth is usually 2 cm. The width is usually 2 cm. The player carries 25 pebbles.
A red rubber ball is carried by the player. The depth is 5 cm. The width is 5 cm. The height is 5 cm.
An arrow is carried by the player. The height is 40 cm. The width is 1 cm. The depth is 1 cm.
A crusty baguette is carried by the player. The height is 80 cm. The width is 4 cm. The depth is 5 cm.
A child's book is carried by the player. The height is 1 cm. The width is 9 cm. The depth is 9 cm.
A featureless white cube is carried by the player. The height is 6 cm. The width is 6 cm. The depth is 6 cm.
Test me with "put arrow in box / put book in box / put cube in box / put ball in box / put baguette in box / put pebbles in box".
Several warnings about this. First, the numbers can't go very high (if the Settings for the project set the story file format to the Z-machine): while the volume can in theory go to 32,767, in practice this equates to an object 32 cm on a side, which is not very large. One way to avoid this is to use the Glulx format, allowing for sizes in excess of 10 m on a side: or we could simply scale the dimensions to suit our purposes, using a decimeter (10 cm) as the basic unit of measurement, for instance.
Second, the system will require a height, width, and depth for every portable object in the game, which is a large commitment to data entry; it may become tiresome. So it is probably not worth bothering with this kind of simulation unless it is going to be genuinely significant.
The following is not a very sophisticated approach, because it does not allow for weight to accumulate: if we put a gold ingot into a paper bag, then put the bag on the balance platform, only the bag's weight will register. But it will do for a first try.
"Dimensions"
A length is a kind of value. 10m specifies a length. An area is a kind of value. 10 sq m specifies an area. A length times a length specifies an area.
A weight is a kind of value. 10kg specifies a weight. Everything has a weight.
The verb to weigh means the weight property. A thing usually weighs 1kg.
Definition: A thing is light if its weight is 3kg or less.
Definition: A thing is heavy if its weight is 10kg or more.
The Weighbridge is a room.
A blackboard is in the Weighbridge. "A blackboard propped against one wall reads: '122/10 is [122 divided by 10] remainder [remainder after dividing 122 by 10]; 122kg/10kg is [122kg divided by 10kg] remainder [remainder after dividing 122kg by 10kg]; 122kg/10 is [122kg divided by 10] remainder [remainder after dividing 122kg by 10].'" The blackboard weighs 10kg.
A feather and a lead pig are in the Weighbridge. The lead pig weighs 45kg.
The balance platform is a supporter in the Weighbridge. "The balance platform is 10m by 8m, giving it an area of [10m multiplied by 8m], currently weighing [the list of things on the platform]. The scale alongside reads: [total weight of things on the platform]. [if two things are on the platform]Average weight is: [the total weight of things on the platform divided by the number of things on the platform]. Heaviest item is [the heaviest thing on the platform], at [weight of the heaviest thing on the platform]. Lightest item is [the lightest thing on the platform], at [weight of the lightest thing on the platform].[otherwise]It seems to be able to weigh several things at once."
Test me with "get feather / put it on platform / look / get pig / put it on platform / look".
Suppose that we have a number of objects in the game that are sized in some conventional unit (such as meters), but which we would like to describe in slightly less formal terms. To do this, we will start with measurements as defined in the built-in extension Metric Units, so we don't have to recreate all these.
We'll add our own set of "conceptual units" -- things we're familiar with in real life. As we'll see below, Inform will automatically choose a unit of the right order to express a given distance if we tell it to print a length "in conceptual units".
Note: the following will compile only if you have settings set for Glulx. (To change this, go to the Settings panel and click on the Glulx option.) The Glulx virtual machine is capable of handling larger numbers than the Z-machine.
"The Speed of Thought"
Section 1 - Procedure
Include Metric Units by Graham Nelson.
1 quarter (in conceptual units, in quarters, singular) or 2 quarters (in conceptual units, in quarters, plural) specifies a length equivalent to 24mm.
1 pencil (in conceptual units, in pencils, singular) or 2 pencils (in conceptual units, in pencils, plural) specifies a length equivalent to 18cm.
1 bathtub (in conceptual units, in bathtubs, singular) or 2 bathtubs (in conceptual units, in bathtubs, plural) specifies a length equivalent to 152cm.
1 Olympic swimming pool (in conceptual units, in Olympic swimming pools, singular) or 2 Olympic swimming pools (in conceptual units, in Olympic swimming pools, plural) specifies a length equivalent to 50 meters.
1 Empire state building (in conceptual units, in Empire State buildings, singular) or 2 Empire State buildings (in conceptual units, in Empire State buildings, plural) specifies a length equivalent to 443m.
1 credit card (in conceptual units, in credit cards, singular) or 2 credit cards (in conceptual units, in credit cards, plural) specifies an area equivalent to 46 sq cm.
1 letter sheet (in conceptual units, in letter sheets, singular) or 2 letter sheets (in conceptual units, in letter sheets, plural) specifies an area equivalent to 603 sq cm.
1 queen-sized mattress (in conceptual units, in queen-sized mattresses, singular) or 2 queen-sized mattresses (in conceptual units, in queen-sized mattresses, plural) specifies an area equivalent to 3 square meters.
1 football field (in conceptual units, in football fields, singular) or 2 football fields (in conceptual units, in football fields, plural) specifies an area equivalent to 5351 square meters.
Understand "report [something]" as reporting. Reporting is an action applying to one thing.
Check reporting:
if the noun is not a fact:
say "The public doesn't want to hear about [the noun]." instead.
Carry out reporting:
now the noun is nowhere.
Report reporting:
if the extent of the noun is greater than 0mm and the surface of the noun is greater than 0 sq cm:
contextualize "'[The noun] has a length of [about] [extent of the noun in conceptual units] and an area of [about] [surface of the noun in conceptual units].'";
otherwise if the extent of the noun is greater than 0mm:
contextualize "'[The noun] has a length of [about] [extent of the noun in conceptual units].'";
otherwise if the surface of the noun is greater than 0 sq cm:
contextualize "'[The noun] has an area of [about] [surface of the noun in conceptual units].'";
otherwise:
say "'[The noun] is... pretty hard to imagine,' you say weakly. That's not going to go over well."
To say about:
say "[one of]roughly[or]about[or]around[or]approximately[at random]";
To contextualize (chosen information - text):
say "[one of]You turn to the camera and speak:[or][or]Turning to another camera angle, you add:[or][stopping] ";
say "[chosen information] ";
say "[one of][line break][or]Right now the station will be cutting over to a visual of that.[or][line break][or]Pity the kids in audiovisual who have to scare that image together in a hurry.[or]You smile brightly.[stopping]";
Section 2 - Scenario
The Science Journalism Desk is a room. "From here you, the Science Anchor, have the privilege of reporting the latest and most fascinating stories to an eager public."
After looking:
try thinking.
Instead of thinking:
say "Currently you have to report on the International Space Station. Your story could include [the list of facts carried by the player]."
Instead of taking inventory:
say "It looks foolish to be fiddling with your possessions on camera."
Instead of dropping a fact:
say "You decide to omit [the noun] from your lineup.";
now the noun is nowhere.
A fact is a kind of thing. Every fact is carried by the player. A fact has a length called the extent. A fact has an area called the surface.
The experiment module is a fact. The extent is 1116cm.
The logistics module is a fact. The extent is 421cm.
The solar array is a fact. The surface is 375 sq m. The extent is 58m.
An individual solar cell is a fact. The surface is 8 sq cm.
The orbit height is a fact.
Report reporting the orbit height:
contextualize "'The station orbits at heights between [about] [278km in conceptual units] and [460km in conceptual units] above the earth.'" instead.
Every turn:
if the player carries no facts:
say "And that's all! The channel cuts to weather.";
end the story saying "Time for lunch".
Test me with "report experiment module / report logistics / report height / report array / report solar cell".