| Chapter 4: Kinds |

| 4.13. Review of Chapter 4: Kinds

1. Kinds are fundamental sorts of object. Inform comes with a certain number of kinds, but we can create more. This can help us if we need a number of identical objects, or many items that share a great deal of common behavior.

An item may belong to only one primary kind. For instance, if we say

> Fred is a man.

then, because a man is a kind of person, and a person is a kind of thing, Fred will also be understood to be a person and a thing. On the other hand, Fred will not also be a woman, a vehicle, or a container, since those are all incompatible with the "man" kind.

2. When we create a new kind, we can give Inform instructions about properties that belong to things of this kind. The following are equivalent:

> A box is a kind of container which is closed and openable.
> A box is a kind of container. A box is usually closed and openable.
> A box is a kind of container. A box is seldom open and unopenable.

Each of these statements instructs Inform that boxes in general have these characteristics, though a particular box might begin the game in a different state, as in

> The player carries a box which is open.

We may also write a more absolute instruction, as in these equivalent lines:

> A box is a kind of container. A box is always closed and openable.
> A box is a kind of container. A box is never open and unopenable.

These instructions tell Inform that we may never begin play with any box defined to be open, so that this time if our source text includes

> The player carries a box which is open.

we will receive a problem message. Inform attempts to construct the simplest possible model of the world based on the information we provide, and anything we tell it directly will override the other assumptions it might make.

Note also that "A box is never open" only specifies that the author may not make the box open at the start of play. The player will still be able to open the box during the game.

We may not say, though it might seem natural,

> A crate is a kind of open container.

After "kind of...", only the name of a kind may follow, with no adjectives. (This is because a kind is a permanent affiliation: once a crate, always a crate, and similarly for containers, whereas the adjective "open" describes an either/or property that comes and goes.)

We also may not assign "usual" either/or properties to kinds already defined by Inform. For instance, the following would not be effective:

> A door is usually open.
> A container is usually openable.

3. In addition to either/or properties (such as open vs. closed), things may have numerical properties (with values such as 10) or textual ones (such as "red"). We may set these as well:

> The printed name of a box is usually "cardboard box".
> The printed name of a room is usually "Here".
> The initial appearance of a person is usually "[printed name] stands nearby, looking gloomy."
> The description of a container is usually "A grubby box held together with silver tape."
> The carrying capacity of a container is usually 3.

4. We may not give properties to an object unless we have said that the object can have these properties; so, for instance, Inform would complain if we tried to say

> Fred is a man. Fred is open.

(Inform knows that doors and containers can be open, but it doesn't think men can be.) We may say that a thing or class has an either/or property by saying, for instance,

> Fred can be open.
> A man can be open.

or, equivalently,

> Fred can be closed.

We may say that something can have a text, value, or thing property by saying

> A room has a number called size.
> A supporter has some text called the description from inside.
> A bus transfer has a time called the expiration time.
> A liquid has a thing called the source spring.

or even

> A container has a rule called the opening result rule.
> A prop has a scene called the use scene.

We will learn more about rules and scenes later; in practice these are the properties we are least likely to need. (For a full list of all the named kinds of value built in to Inform, see the chapter on extensions.)

5. We may define our own new kinds of value, to represent states of things within our model world. These kinds of value may be used as properties of individual things or of entire kinds. So for instance:

> Brightness is a kind of value. The brightnesses are dim, shining, and blazing. A lamp is a kind of thing. A lamp has a brightness. A lamp is usually blazing. The hurricane lamp is a lamp.

Unless we arrange otherwise, a value property can be referred to simply by the name of the value, as here, "the brightness of the hurricane lamp". If, on the other hand, we wanted to associate two brightnesses with the lamp, we might say

> A lamp has a brightness called maximum brightness. A lamp has a brightness called current brightness.

Now we may no longer add

> A lamp is usually blazing.

since Inform will not know whether "blazing" is meant to be the current brightness of the lamp or the maximum brightness; so we will have to be more specific, as

> The maximum brightness of a lamp is usually blazing.
> The maximum brightness of the hurricane lamp is shining.
> The current brightness of the hurricane lamp is dim.

and so on.

6. Once we have made a kind, we may create multiple objects of this type without giving them individual names. For instance, we might say:

> A coin is a kind of thing. The player carries three coins.
> A basket is a kind of container. 13 baskets are on the shelf.

There are two points to note here. First, numbers over twelve may not be spelled out, and must be given numerically. Second, if we do not define a kind first,

> The player carries three coins.

will instead produce a single object whose name is "three coins".

We are also allowed to make general rules about how parts and objects are distributed, so:

> A nose is a kind of thing. A nose is part of every person.
> A spray of lavender is a kind of thing. Three sprays of lavender are in every gardening basket.

A few restrictions apply here. First, we may not use "room", "supporter", or "container" in these sentences; second, when we say "Three sprays of lavender are in every gardening basket", "spray of lavender" and "gardening basket" must both be names of kinds.

Inform will often be able to guess about the correct plural of a given word, but will sometimes need correction:

> An ox is a kind of animal. The plural of ox is oxen.

7. The name of a kind will not automatically be understood to refer to an item of that kind: for instance

> The glass bottle is a container.

will not mean that the glass bottle responds to

> >TAKE CONTAINER

and

> Philippe is a man in the Botanical Garden.

will not allow the player to refer to Philippe as "the man". We can get around this using an instruction from later:

> Understand "man" as Philippe.

Or, more generally,

> Understand "man" as a man.

...in which case, all men can be referred to as "man".

The exception is that if we have created items without giving them names, as in

> The player carries a container.

the name of the item will be the name of its kind, so that in this instance the player will see

> You are carrying:
> a container

and the game will respond to "TAKE CONTAINER".

Previous | Contents | Next