Saturday, February 23, 2019

Chapter 7. PARESR: How Now Brown Cow (Part 3) - Updates (Actors, Adverbs, and Numbers)

7.8 Update: Speaking to Actors with Quotes

The first modification to PARSER began with Zork 2 and relates to double quotes in commands. A double quote is treated like an end-of-command token like THEN or period. It also toggles the QUOTE-FLAG which is essentially a flag for finding an another double quote. The first double quote seen sets that flag. A second will clear it.
In Zork 2, the use of a double quote comes into play in several special situations.When the player says something out loud such as SAY “ABRACADABRA”, the game will typically ignore these commands unless you are saying special words for a spell or a riddle. The game will then pull out the word after the first double quote and use it to trigger other routines.
PARSER will also handle speaking to the other actors using quotes. Actors are characters in the game that can be asked questions or perform actions. They are created using objects and have the PERSONBIT set. Using interrupts, the game can have the actors move or perform other actions on their own. To have an actor perform an action like:

TELL WIZARD “TURN OFF THE LAMP”

PARSER first divides up the command into two separate commands with the double quote as the terminating token for both commands. So the previous command becomes:

TELL WIZARD“ and
TURN OFF THE LAMP”

To have actors perform actions, PERFORM (discussed later) will call the TELL/ASK routine first which ensure the direct object is a person (PERSONBIT) and then set WINNER to the actor. PARSER will then process the second command with the actor as the WINNER. The individual action routines handle these special situation where actors perform the commands by checking the value of WINNER. Later, PARSER will ensure that WINNER is set back to the player on its next execution by detecting a clear QUOTE-FLAG and WINNER not set to the player.
Deadline expanded the methods for interacting with actors by allowing commands in these formats:

  • TELL/ASK actor TO command
  • Actor THEN command
PARSER would change the TO or THEN tokens to a double quote token which is then treated as an end-of-command token just like it was back in Zork 2. The verb number in ITBL would automatically be set to the verb number for TELL if the second format is used. HGTG later added a check to ensure the token after TO was a verb which indicated the start of another command.
The player in Deadline could also refer to actors with their name followed by a comma:

Actor, command

PARSER (through CLAUSE) considers as a end-of-command between two commands. The comma is then changed to “then” and processed like in the other formats.
Deadline also allowed the PLAYER to ask the actors directly about an object or ask them to give you an object using:

  • ASK actor ABOUT object
  • ASK actor FOR object
These are treated like any other command and depend on the object attributes.
Finally, Deadline also introduced a new routine which checks if the requested actor is in the current location and if the subsequent command is appropriate (action is WHAT, FIND, TELL, or SHOW) before allowing the commands to be processed. This check would be added to subsequent games.

PERFORM will call the TELL/ASK routine which ensure the direct object is a person (PERSONBIT) and then set WINNER to the actor. PARSER will then process the second command with the actor as the WINNER.

7.9 Update: Titles and Adverbs (briefly)

The recognition of titles used to address actors like MRS. or MR. and automatically skip them along with any following period was introduced with Deadline.  The game also recognized 5 specific adverbs (CAREFULLY, QUIETLY, SLOWLY, QUICKLY, and BRIEFLY) and saved the adverb’s Vocabulary address in ADVERB. It would be used later by specific action routines such as WATCH, GO, or READ. The adverbs were considered a special token and not a specific part of speech. Bureaucracy is the only game with adverbs, but they are not needed to complete the game.

7.10 Update: Numbers, a new object

Deadline introduce numbers and time to Infocom games. Since these values do not match with any token, they are given a $0000 Vocabulary address. NUMBER? will then change the $0000 to the vocabulary address for a “intnum” or “number” token. A special global variable contains the numerical value. For time values, the time in minutes is saved:
  1. 1. Loop through all the characters of an unknown token
  2. 2. If the character is a digit, then take the current sum, multiply it by 10, and add this value of this digit.
  3. 3. If a “:” is found, then the previous digits are likely an hour value. Save this into a separate TIM variable and reset the total sum. Continue looping through the remaining digits which will be the minutes value.
  4. 4. Once all the digits are read (and there are no extra non-digit characters), then the sum (value of the digits) is save into P-NUMBER and this unknown token is given the Vocabulary address for “intnum”.
  5. 5. If the sum is greater than 10000, then the routine will return FALSE.
  6. 6. If the number was an time value, then the sum is actually the minutes value. The routine will take the hour value and multiply it by 60 and then add the sum. If the hour value is greater than 23, then the routine will return FALSE. There is no restriction on the size of the minutes value though. This new sum (time in minutes) is also saved in P-NUMBER.

Routines can then search for the “intnum” token and use the value in the corresponding global variable. Because of this design, only one number or time value could be used in each command. Games using time values can impose certain restrictions on the what hours are valid. For example, Deadline considers any time between 1:00 and 7:59 to be PM. So 7:00 is converted to 19:00 (or 7pm) for the game. Hours from 0 to 23 are considered valid for all games. Most games will convert the hour and minutes into all minutes. Only Sherlock checks the value of the minutes. So a time value of 14:80 could be valid in most games that use time as they are converted to all minutes.
More number formats would be recognized in later games. They are listed below:
Added Format
Game Introduced
Notes
$xxx
Cutthroat
No cents portion is allowed. The value is saved in a different global variable than P-NUMBER. The “intnum” object has it’s property 11 set to “amount of money”.
xxx-yyyy
Suspect
The phone number is stored as two separate numbers in separate global variables
xxx,xxx
LGOP
Comma separated number is converted to a single 4-6 digit number
xx(B-E)
$xxx.yy
#xxxx
Bureaucracy
Number followed by letters B-E indicates seat row and letter (4 times row # + seat letter converted to 0-3 value) and money value (converted to cents) are saved in their own special global values. The object type returned is “intnum” except for a money value where “money” is used. If a # starts a number, it is ignored.
HH:MM AM/PM
Sherlock
The hour is converted to the corresponding 24 hour value. The entire time is saved in the game’s special time table format

No comments:

Post a Comment