10.5. Volume, Height, Weight

| Chapter 10: Physics: Substances, Ropes, Energy and Weight |

| 10.5. Volume, Height, Weight

What should fit into what? Inform has basically three sizes: small, person-sized, and room-sized. The difference between "small" and "person-sized" doesn't appear much, but it's the difference between an ordinary container and an enterable container; the fact that a person cannot get inside an ordinary container is one of the few size-related rules built into Inform. It will not object to, say, a fishing rod being put inside a matchbox.

Inform does have one built-in measure of the size of a container: its "capacity". This is a maximum number of contents:

> The capacity of the rucksack is 3.

This of course allows three anvils, while forbidding four postage stamps. To do better, we need units of measurement, and Dimensions demonstrates setting these up. The Speed of Thought, meanwhile, ventures into the area of unit conversion: having multiple types of unit and being able to express them to the player, or parse these in the player's input.

To be fully realistic in what will fit into what, we need sophisticated three-dimensional models of shapes, both of the items being carried and of the free space remaining inside containers. Depth elegantly simplifies this by approximating items as cuboids, with a given width, length and height: these multiply to give a volume. To fit in a container, a new item's volume must not exceed the volume remaining inside the container, and in addition its three dimensions must also fit in one of the possible arrangements at right angles to the sides. (So this system would indeed prevent a 1x1x100 fishing rod from being put inside a 5x2x1 matchbox, but would also prevent a 12x1x1 pencil from being put into a 10x10x1 box, because it would need to be turned diagonally to fit.)

Lead Cuts Paper provides a different constraint: here we do not let light-weight containers hold heavy objects.

Weight comes in a different way into Swerve left? Swerve right? Or think about it and die?, which exploits up/down map connections to work out which way gravity would take a rolling marble.

See Liquids for containers with liquid capacity

247
| Example Dimensions This example draws together the previous snippets into a working implementation of the weighbridge. |
WI

259
| Example The Speed of Thought Describing scientifically-measured objects in units more familiar to the casual audience. |
WI

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: remove the noun from play. 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."; remove the noun from play. 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".

257
| Example Depth Receptacles that calculate internal volume and the amount of room available, and cannot be overfilled. |
WI

248
| Example Lead Cuts Paper To give every container a breaking strain, that is, a maximum weight of contents which it can bear - so that to put the lead pig into a paper bag invites disaster. |
WI

231
| Example Swerve left? Swerve right? Or think about it and die? Building a marble chute track in which a dropped marble will automatically roll downhill. |
WI

Previous | Contents | Next