| Chapter 4: Kinds |

| 4.4. Duplicates

Although it is only useful to a limited extent, we can make any number of copies of something:

> "Polygons"

> A shape is a kind of thing. A square is a kind of shape. A triangle is a kind of shape.

> The Geometry Lab is a room. In the Geometry Lab are three triangles and two squares.

The description "three triangles" makes three identical things, each of the kind "triangle", and similarly for the squares. When the above is compiled, the player can type "take two triangles" or "take all the triangles" and so forth.

Three caveats. Firstly, a counted-out description like "two squares" is only allowed if it combines a number with the name of a kind which is already known (perhaps modified with adjectives, so "two open doors" is fine). If we say:

> Two circles are in the Lab.

without having defined "circle" as a kind in advance, then only a single object will be created - whose name is "two circles". (This is because many natural names start with numbers: "six of clubs", for instance, referring to a single playing card, or "12 Hollywood Close" meaning a single house. We wouldn't want such names to be misinterpreted.)

The second caveat is that excessive duplication is expensive in memory and running time. It is perfectly legal to say

> In the Lab are 75 triangles.

but the resulting game may be a little sluggish: and Inform draws the line at 100, refusing to create more duplicates than that in any single place. If we really need more than about fifty duplicated objects - say, a tombola containing raffle tickets numbered 1 to 1000 - it is usually better to find some less literal way to simulate this: for instance, only having a single raffle ticket, but with a randomly chosen number on it.

Finally: numbers up to twelve may be written out, but larger ones must be written as numerals. So "twelve" or "12", but "13" only.

38
| Example Early Childhood A child's set of building blocks, which come in three different colours - red, green and blue - but which can be repainted during play.

Previous | Contents | Next