| Chapter 5: Text |

| 5.3. Text with numbers

When a numerical value is given in a square-bracketed substitution, it is ordinarily printed out in digits. Thus:

> "You've been wandering around for [turn count] turns now."

might print as "You've been wandering around for 213 turns now.", if the game has been played out for exactly that many commands. Alternatively, we can add "...in words", thus:

> "You've been wandering around for [turn count in words] turns now."

to get the more conversational "You've been wandering around for two hundred and thirteen turns now."

Either way, though, there is some risk of the following:

> You've been wandering around for one turns now.

We can avoid this using the special substitution "[s]", which prints a letter "s" unless the last number printed was 1. So:

> "You've been wandering around for [turn count in words] turn[s] now."

will produce "... for one turn now." or "... for two turns now." as appropriate. This only solves one case (what about all the other plural endings, from "women" to "cherubim"?), and as we shall see we can get the same effect and very much more using the methods in the next section, so "[s]" is something of an anomaly. But it's memorable, and even if it only solves one small need, this is a need which turns up often.

49
| Example Ballpark A new "to say" definition which allows the author to say "[a number in round numbers]" and get verbal descriptions like "a couple of" or "a few" as a result.

> Sometimes it is more sensible to describe numbers roughly than in exact terms. For instance, we might want to have our player perceive "many people" rather than "forty-two people" on entering a room. To achieve this, we might write our own "to say" phrase. "Ballpark" To say (count - a number) in round numbers: repeat through the Table of Numerical Approximation begin; if count is less than threshold entry begin; say "[approximation entry]"; rule succeeds; end if; end repeat. Phrases will be explained more thoroughly in a later chapter, but as we have already seen in the examples, we can make a "To say..." phrase that will allow us to create our own text substitutions. In this case, we are going to replace the specific number with a vaguer one chosen from a chart, so: Table of Numerical Approximation
> threshold | approximation
> 1 | "no"
> 2 | "one"
> 3 | "a couple of"
> 6 | "a few"
> 11 | "some"
> 21 | "many"
> 1000 | "lots and lots of"
The idea here is that we will work our way through the table until we hit a line where the threshold number is higher than the number we want to express, and then print that output: so if we have less than one item, we'll print "no"; if we have more than none but less than two, we'll print "one"; if we have less than three, we'll print "a couple of"; if we have three, four, or five (but not six), we'll print "a few." A room has a number called the population. The population of a room is usually 0. The description of a room is usually "You observe [population of the location in round numbers] [if population of the location is 1]person [otherwise]people [end if]here.". The Stadium is a room. The Hot Dog Stand is west of the Stadium. The Women's Restroom is south of the Stadium. The population of the Stadium is 500. The population of the Hot Dog Stand is 3. The population of the Restroom is 750. Test me with "w / e / s".

Previous | Contents | Next