Creating or specifying custom adjectives.
using adjectives to describe the worlds of our games
adjectives in general.
In everyday spoken English, we use adjectives to describe and specify nouns. We might refer to a tall building or a lovely song. A bird might be blue or black. Adjectives are frequently discussed in Inform’s Standard rules, and why wouldn’t they? If we are programming with natural language, it only makes sense that we will sometimes need to characterize the things populating the worlds we make.
The use of the word “adjective” in the Inform documentation is not always technical. Here is its first use, which reasonably assumes that we know what the English word “adjective”means:
WI §3.6 Either/or properties
Some containers, like bottles, can be opened: others, like buckets, cannot. If they can be opened, then sometimes they will be open, and sometimes closed. These are examples of properties, which can change during play. The following source sets some properties:
``````
The cardboard box is a closed container. The glass bottle is a transparent open container. The box is fixed in place and openable.
There are only four different properties referred to here. Closed means not open, and vice versa, so these two adjectives both refer to the same property. (As might be expected, when a container is open, one can see inside and place things within, or take them out.) The glass bottle and the box being containers is a matter of their kinds, which is something fundamental and immutable, so "container" does not count as a property.
This is not a technical usage of the term “adjective.” Rather, we see here that properties (a technical term) can be used as adjectives within our phrases and sentences. For instance, a box with the open property can be identified as such:
if the box [a thing] is open
...
if there is an open box [a kind] in the location
...
repeat with B running through open boxes [a kind]
The designation an open box (used as a kind) is what Inform calls a “description of values.” While this terminology might seem confusing at first, it is straightforward enough.
- “description” = described by an adjective
- “values” = while we might initially think of values as abstractions, kinds of things (in this case, boxes) are values, too.
defining new adjectives
Creating a property is one way to make adjectives that we can use in our code.
a thing can be red or blue.
...
a thing can be red.
In both cases, Inform will assign all things a default property. This will always be the second value (if no second value is stated, the assumed second is, for instance, “not red” or the absence of red).
after examining the box:
now the box is red;
In other words, creating a property has implications for all things of the world, and that property can be assigned (or not) by default or else by specific code.
Sometimes, it will be desirable—perhaps very desirable—to let inform decide whether or not an adjective applies to something. Things that are carried by the player—not stowed in a bag, mind you, but carried “bare-handed,” so to speak, can be referred to with the adjective carried. Under the hood, the adjective carried is not assigned in the way that red (above) is. Instead, it is derived from a relation.
From the Standard Rules:
The verb to carry means the carrying relation.
We don’t need to be experts in relations to take advantage of this. We can make sentences straight away. For instance:
lab is a room.
the player carries the wallet.
instead of jumping:
if the player carries the wallet, say "The player carries the wallet!";
if the player is carrying the wallet, say "The player is carrying the wallet!";
if the wallet is carried by the player, say "The wallet is carried by the player!";
This yields
>jump
The player carries the wallet!
The player is carrying the wallet!
The wallet is carried by the player!
That’s all quite handy, and, once we’re used to working with relations, we can write such sentences with ease. However, Inform offers ways for us to write other phrases and conditions based on these relationships. Using “definitions,” we can craft adjectives to use in our phrases and sentences. Again, from the Standard Rules:
Definition: a thing is carried if the player is carrying it.
Initially, the significance might not be clear, as there doesn’t seem to be meaningful difference between phrases like these:
if the player carries the frob
...
if the frob is a carried thing
In fact, the one with the adjective seems to be the more awkward of the two. Let’s try again.
repeat with T running through things:
if the player carries T:
...
repeat with T running through carried things:
In that case, the second one requires less typing and is more readable, too.
after stumbling:
try dropping a random carried thing;
We need not limit ourselves to relations, though. We can devise custom adjectives based on any number of considerations.
a diving board has a number called height.
definition: a diving board is high if the height of it is greater than 10;
Definitions always begin with “definition:” What immediately follows is our adjective (“high”). Next comes a condition. Note that we can use “it” freely here; Inform knows that we refer to the thing defined.
We can use it straight away. Perhaps our protagonist is afraid of heights:
does the player mean climbing a high diving board:
it is very unlikely;
or
before climbing a high diving board:
say "Gathering your courage, you make your way up the tall, narrow laddder.""
Sometimes, we might incorporate both an affirmative and negative adjective in our definition.
definition: a diving board is high rather low than if the height of it is greater than 10;
Using the “rather than” construction allows us to name a second, opposing adjective.
At least, sometimes we can. Some definitions are too complex to allow a negative counterpart in-line. Consider this familiar-looking construction:
definition: a person is frightened if:
if it is on a high diving board, decide yes;
decide no;
In such cases, we might want to define the negative ourselves using the definition we just made.
definition: a person is sanguine if:
if a person is frightened, decide no;
decide yes;
If you read last week’s post, then you’ve likely noticed how similar this practice looks to a phrase defining a new condition. Both push toward a yes or no question: the conditions have been met, or they haven’t. The board is high, or it isn’t. The main difference comes down to application: defined conditions can be used broadly to talk about just about anything. The condition is whatever we name it. Defining an adjective, on the other hand, modifies something more specific. “definition: a frob is…” can only compile if there is someplace within our code a frob to describe.
Perhaps we need a list of things the player left in the opening section of the game.
lab is a room.
starting area is a region.
the point of origin is in starting area.
the widget is in the point of origin.
the frob is in the point of origin.
definition: a thing is left behind if it is in the starting area and the player is not in the starting area.
after jumping:
say "You have left behind the [the list of left behind things].";
In this case, a left behind thing is anything that is in the starting area when the player is not. However, we may have been a little too loose with our definition. Let’s make sure we aren’t talking about scenery, since players can’t bring that with them:
definition: a thing is left behind if it is not scenery and it is in the starting area and the player is not in the starting area.
alernately:
definition: a thing is left behind:
if it is scenery, decide no;
if the player is in the starting area, decide no;
decide yes;
There! Applying the scenery adjective gives us the specificity we need. If we wished to only include things the player has carried, we could specify “handled” instead.
These most recent examples are computed. This is an important distinction! We never need to tell Inform that the frob is left behind, because it can work that out based on the definition we have provided. This differs from the adjectives we’ve discussed in the past: those are assigned via either defaults or else more specific code.
In both cases, though, we are using adjectives to designate something in the world of our game, and, like phrases defining new conditions, adjectives can empower us to write more effective and readable code.
Further reading: WI 11. Phrases
