Chapter 11: Out Of World Actions and Effects
11.4. Scoring

Not every work of IF allots a numerical score to the player: for some authors, this emphasises the idea of a game rather than a narrative. The simple sentence

Use no scoring.

abolishes the concept. Otherwise, Inform will provide built-in support for a single number measuring progress ("score"), and will expect to measure this against a maximum possible ("maximum score", which can either be set by hand or worked out automatically from a table of ranks).

In a game in which scoring exists, the player may choose to turn score notifications (such as "[Your score has just gone up by one point.]") on or off. The commands to do this are NOTIFY ON and NOTIFY OFF; the actions are called switching score notification on and switching score notification off. In the event that we need to amend the behavior of notification, we could do so by adding, removing, or modifying the elements of the check and carry out rulebooks for these commands; as in

Check switching score notification off:
    if the turn count is less than 10:
        say "You are still a novice, grasshopper. Allow your teacher to give you advice until such time as you are ready to go on alone."

If we wish to change the wording of the default message ("[Your score has..."), we may want to resort to extensions available from the Inform website which allow access to all the default messages in a game.

An especially insidious style of bug allows the player to type the same sequence of commands over and over, earning score endlessly for the same insight, and to avoid this it is usually safest to write source like:

After taking the Picasso miniature when the Picasso miniature is not handled:
    award 10 points; say "As they say in Montmartre: dude!"

We might also write our condition with "for the first time", like so:

After jumping for the first time:
    award 5 points;
    say "Boing! That was certainly entertaining."

But we should be careful not to use "for the first time" in scoring situations where it's possible for the player to try the action but fail. Inform counts even unsuccessful attempts towards the number of times an action is understood to have occurred, so if the player tries to jump and fails, his "for the first time" will be used up and he will never receive the score points.

If there are many "treasure" items like the Picasso miniature, it is best to be systematic, as in No Place Like Home. Bosch takes another approach to the same idea, by creating a table of point-earning actions that the player will be rewarded for doing; the FULL SCORE command will then play these back.

Mutt's Adventure demonstrates how we might add a scored room feature, such that the player earns a point when he first arrives at a special room.

A single number does not really sum up a life, or even an afternoon, and Goat-Cheese and Sage Chicken and Panache offer more detailed citations. Works that are more story than game may prefer to offer a plot summary of the player's experience to date in lieu of more conventional scoring.

Finally, Rubies provides a scoreboard that keeps track of the ten highest-scoring players from one playthrough to the next.


137
*** Example  No Place Like Home
Recording a whole table of scores for specific treasures.

WI
220
* Example  Bosch
Creating a list of actions that will earn the player points, and using this both to change the score and to give FULL SCORE reports.

WI
136
** Example  Mutt's Adventure
Awarding points for visiting a room for the first time.

WI
269
*** Example  Goat-Cheese and Sage Chicken
Implementing a FULL SCORE command which lists more information than the regular SCORE command, adding times and rankings, as an extension of the example given in this chapter.

WI
166
*** Example  Panache
Replacing the score with a plot summary that records the events of the plot, scene by scene.

WI
431
*** Example  Rubies
A scoreboard that keeps track of the ten highest-scoring players from one playthrough to the next, adding the player's name if he has done well enough.

WI

The trick here is that we need a table with indexed text in order to keep track of the players' names.

Part 1 largely replicates the source from "Identity Theft"; new material starts at Part 2.

"Rubies"

Part 1 - Collecting Names

The player's forename is an indexed text that varies. The player's full name is an indexed text that varies.

When play begins:
    now the command prompt is "What is your name? > ".

To decide whether collecting names:
    if the command prompt is "What is your name? > ", yes;
    no.

After reading a command when collecting names:
    if the number of words in the player's command is greater than 5:
        say "[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let's try this again.";
        reject the player's command;
    now the player's full name is the player's command;
    now the player's forename is word number 1 in the player's command;
    now the command prompt is ">";
    say "Hi, [player's forename]!";
    say "[banner text]";
    move the player to the location;
    reject the player's command.

Instead of looking when collecting names: do nothing.

Rule for printing the banner text when collecting names: do nothing.

Rule for constructing the status line when collecting names: do nothing.

Part 2 - Adding the Leaderboard

File of Leaderboard is called "leaderboard".

When play begins:
    if the File of Leaderboard exists:
        read File of Leaderboard into the Table of Leaders;
        sort the Table of Leaders in reverse scored amount order.

When play ends:
    choose row 10 in the Table of Leaders; [we've sorted the table, so the lowest score will be the one at the bottom]
    if the score is greater than scored amount entry:
        now name entry is the player's forename;
        now the scored amount entry is the score;
    show leaderboard;
    write the File of Leaderboard from the Table of Leaders.

To show leaderboard:
    sort the Table of Leaders in reverse scored amount order;
    say "Current leading scores: [paragraph break]";
    say fixed letter spacing;
    repeat through Table of Leaders:
        if scored amount entry is greater than 0:
            say " [name entry]";
            let N be 25 minus the number of characters in name entry; [here we want to space out the scores so they make a neat column]
            if N is less than 1, now N is 1;
            say N spaces;
            say "[scored amount entry][line break]";
    say variable letter spacing.

To say (N - a number) spaces:
    repeat with index running from 1 to N:
        say " ".

Table of Leaders
scored amount   name (indexed text)   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   
0   "Smithee"   

And now we introduce a scenario that allows different players to come up with different scores -- admittedly not a very interesting scenario, but it will do for now:

Part 3 - Scenario

Carry out taking something which is not handled:
    increment score.

The Big Treasure Chamber is a room. It contains a ruby, an emerald, a gold tooth, an antique katana, and a silver coin.

Instead of waiting, end the story finally.

Test me with "get ruby / z".


PreviousContentsNext