| Chapter 18: Rulebooks |

| 18.16. Two rulebooks used internally

Rulebooks handle almost all of the important tasks which an Inform work of IF must carry out in order to keep play going. We have seen them used in clarifying the player's command, supplying missing ingredients, processing the action to see what should happen, responding, and so on: by this point in the documentation, it must look as if Inform uses rulebooks for everything.

This is nearly true. There is not actually a super-rulebook controlling everything. (Such a super-rulebook would need to repeat itself and never finish, something a rulebook is not allowed to do.) Instead, what happens during play looks like so:

> 1. Following the "when play begins" rulebook.
> 2. Repeating:
> 2(a). Reading and parsing a command into an action;
> 2(b). Following the "action processing" rulebook;
> 2(c). Following the "turn sequence" rulebook.
> until the game has finished.
> 3. Following the "when play ends" rulebook.

The command parser occasionally calls on the services of activity rulebooks to help it, but otherwise gets on with its job in ways that we do not "see" as Inform 7 users. The rest of what happens involves rulebooks, and in particular two important beneath-the-surface rulebooks: action processing and the turn sequence.

The action processing rules are used whenever an action must be tried, by whoever tries it. This usually happens in response to player commands, but not always: it might happen because of a "try...", and it can certainly interrupt an existing action.

The turn sequence rules are used at the end of each turn, and include housekeeping as well as timekeeping. They consult the "every turn" rulebook, and advance the time of day, among other useful tasks.

In general, we should only modify the operation of these two crucial rulebooks as a last resort. Play can evidently fall to pieces if they cease to work normally.

301
| Example Instant EXAMINE and LOOK A set of actions which do not take any game time at all.

In a game with tight timing, it is sometimes friendliest to the player to let him LOOK and EXAMINE as much as necessary without being penalized. Examining something is acting fast. Looking is acting fast. Note that we want to skip the whole turn sequence rulebook (including every turn rules and so on), not just the "advance time rule", which merely moves the clock and turn counter forward: First turn sequence rule: if acting fast, rule succeeds. Thus the rest of the turn sequence rulebook is omitted if that first condition is met. If we wanted to add, say, taking inventory to the list of instant activities, we would just need to define it as acting fast, too. It would be possible to do the same thing with a procedural rule like this: Procedural rule when acting fast: ignore the turn sequence rules. The advantage of the "first turn sequence rule" method is that it avoids adding unnecessarily to the procedural rulebook: as noted elsewhere, procedural rules are extremely powerful but can slow down the game when they are present in large numbers.

302
| Example Electrified Adding a rule before the basic accessibility rule that will prevent the player from touching electrified objects under the wrong circumstances.

Previous | Contents | Next