| Chapter 4: Kinds |

| 4.8. Kinds of value

Several kinds of value have appeared so far, chiefly numbers, 1, 2, 3, ... and 0, -1, -2, ... and texts, such as "Jackdaws love my big sphinx of quartz". We can give objects properties holding such values, and we can also endow them with either/or properties such as "dark"/"lighted".

These arrangements are all very well, but not ideal when it comes to simulating something which can be in, say, one of four states. Suppose we would like the candle lantern to burn down, gradually diminishing in brightness. A property attached to the lantern should hold the current strength of the flame. We could do this like so:

> The lantern has a number called the brightness level.

(Thus far we have only given new properties to kinds, but in fact we can also give them to individual things, as here. It would be cumbersome to make a new kind called, say, "lamp" and then make the lantern the only lamp in the game, just as a way of attaching a number to it.) We could then set the brightness level to be 1, 2, 3 or 4 according to the strength of flame, and find some way of conveying this to the player. That would work, but is not very elegant. Brightness is not, in the end, a number, and it seems strange to have to pretend that it is. A much better solution is:

> Brightness is a kind of value. The brightnesses are guttering, weak, radiant and blazing.

This makes "brightness" a kind of value on a par with (for instance) "number" or "text", except that there are only four possible values, named as above.

Previous | Contents | Next