4 - Lesson Four


4.1 - Synonyms

One of the most important things an adventure game author can do to help someone enjoy his game is to allow multiple wordings for commands. This minimises the chance that the player must play a mini-game of 'guess the verb' to find the name the author has given to a command.

4.1.1 - Verb Synonyms

For example, if 'exit' is not used to leave a location somewhere in the game why not allow that word as an alternative to the 'quit' command? While hopefully players won't be leaving your game so often that they get tired writing 'quit', allowing the abbreviation 'q' is pretty traditional. Fortunately for the game author, you don't need to define extra commands called 'exit' and 'q' but simply list those words as alternatives for 'quit' in a 'synonyms' statement.

(Note that because exit is an Alan keyword - used to define exits from locations - it must be put in quotemarks when we define it as a player-enterable word. The letter q has no special meaning in the Alan language so quote-marks are not required.)

4.1.2 - Direction Synonyms

Synonyms can be defined for any word a player might type while playing a game. Defining abbreviations for direction commands are probably the most helpful because they will probably be the commands players most frequently type.

(Note that, as in the example above, you can list the synonyms for more than one command in one synonym statement. I prefer to define synonyms for each verb with its own separate synonym statement next to the verb's syntax statement. I find it easier to keep track of things that way.)

4.1.3 - Direction names can be anything

Its probably worth noting here that EXIT names don't have to be compass directions. You could define exits called up, in, exit or shazam for example.

4.2 - VISITS Statement

Like synonyms, another feature that often improves the playing experience is to not redisplay a location description when the player revisits a location.

By default, Arun always displays the location description. The game author can change this by using the VISITS statement. If VISITS 99 (or any other big number) appears in the START section of a game, after the initial visit, a location description won't be redisplayed until the player has revisited that location 99 times - effectively it will never be redisplayed.

4.3 - LOOK Statement

At some point after the initial visit the player may want to see the location description again. The LOOK statement prints the description of the current location so we can create a verb containing the LOOK statement so the player can redisplay a location's description whenever they wish. Like the quit and score verbs, the look verb name and Alan statement the verb executes will be the same so we have to put single quote-marks around the verb name.

Also, because it is a single-word verb we need a SYNTAX statement to tell Alan that the verb makes sense on its own. And, as it will be a commonly used command players will appreciate it if we defining an abbreviation with a synonym statement.

4.4 - 'Brief' and 'Verbose' Verbs

Players may not always want VISITS set to 99. At times they may want the location description displayed every time they visit a location. This setting in a text adventure game is traditionally called 'verbose' mode. The opposite is known as 'brief' mode.

We can define brief and verbose verbs to let the player switch between the two modes as they wish. The verbs will execute a visits 0 and a visits 99 statement respectively.

Note that single-quote marks aren't required around the brief and verbose verb names because they are not Alan keywords.

Of course, syntax definitions are required for both the brief and verbose verbs because they are single-word commands. A few synonyms might also be appreciated by the player. So we need something like this in our source code:

4.5 - Verbs and Descriptive Text

Verbs can display text as well as executing Alan statements. This is simply done by putting the required text (inside double-quote marks) in the DOES section of the verb definition.

To display a brief or verbose mode confirmation when the player uses the brief and verbose verbs we could modify the verb definitions like this:

4.6 - Use of Double and Single Quote-Marks

It can be a bit confusing when to use double or single quote-marks in your Alan source code.

The text that will be displayed on screen during the play of a game (such as location descriptions) should be written within double quote marks in the source code. Remember, double-quoted strings are actually 'print-this-text' Alan statements - PRINT statements with the word PRINT left out.

Single-quote marks around the names of locations and verbs etc are used in the source code to distinguish those names from Alan keywords that happen to be spelt the same.


Example Alan source code | Table of Contents | Next Lesson