Monday, February 18, 2019

Chapter 4. Execution of Infocom Games - An Overview

4.1 Introduction

For all of their perceived complexity, Infocom games have a fairly straightforward and consistent method of getting player commands, parsing them, and executing them quickly. Each game would start with initial setting of global variables and interrupts. This loop starts with PARSER getting a command. It will then check and extract all needed grammatical information. The game will use PERFORM to call an action on the various objects in that command. CLOCKER will check and executed any interrupts if necessary. Finally, the program repeats this indefinitely or the game stops. Each game used the same basic code from initialization of the game through handling interrupts. The repeated use of previous code help minimize new bugs and kept the play of the games consistent. But every game had some kind of new code which could introduce bugs.  The description of these main backbone routines will be from the original Zork 1 game from 1979. Information about updates to these routines will then follow each section.

4.2 Initialization with GO

Initialization of each game begins with the GO routine which performs (at least) four required tasks:
  1. Set important game variables like object number for WINNER or starting location
  2. Set any interrupt routines
  3. Display the version information of the game
  4. Execute the LOOK command for the starting location
The game then moves to the MAIN-LOOP.

4.3 Heart Beat of the Game with MAIN-LOOP

The game will repeatedly get new commands and execute them in an indefinite loop, the MAIN-LOOP.  The commands are obtained and parsed using PARSER which returns the action, direct objects, and indirect objects referenced by the given command. This loop will then call PERFORM to execute the given action on all the direct and indirect objects. The turn of the loop will end by calling CLOCKER which executes any necessary interrupts. MAIN-LOOP will then repeat all of these steps indefinitely.

4.4 Understanding the User with PARSER

PARSER takes the player’s input or any remaining input from the last command and extracts the parts of command: verb, direct object, and indirect object. The part of speech of tokens are identified and later used by CLAUSE to find the start and end of object clauses.

4.5 Completing Previous Command with ORPHAN-MERGE

If a previous command was orphaned, the given command is examined to by ORPHAN-MERGE to see if the it supplies missing information from the orphaned command. If so, then ORPHAN-MERGE combines the new information with the previous command. PARSER continues to process this fixed command just like any other command.

4.6 Match the Command with SYNTAX-CHECK

The use of syntax templates allowed Infocom games to understand multiple commands using similar tokens but in different orders. After PARSER identifies the verb, direct object, and indirect object, SYNTAX-CHECK will try to match a syntax template to the given verb, prepositions, and objects. The action with the matched syntax template is returned. If the best matched syntax template still has missing objects, the game will attempt to supply them with objects in the current location.

4.7 Find the Objects with SNARF-OBJECT

After the matching syntax template and objects are verified, the game will process each object clause and match the objects with objects from the game.  It will also handle modifiers like EXCEPT and quantities like ALL.

4.8 Final check on Objects with TAKE-CHECK and MANY-CHECK

The game will also confirm if the objects need to be taken first (TAKE-CHECK) and if multiple objects are allowed for the action (MANY-CHECK). Once all the checks are completed, the game creates a table of all the objects that are referred in each object clause.

4.9 Call the Actions with PERFORM

Finally, the game will execute the requested action (PRSA) on the given direct (PRSO) and indirect (PRSI) objects with PERFORM. If one noun clause has one object but the other has multiple, the game will cycle through the clause with the multiple objects and use the same object for the other clause. However, if both clauses have multiple objects, only the direct objects will be cycled. Only the first indirect object will be used.

4.10 Tick the CLOCKER

After the player command(s) are performed, the game’s interrupt system “ticks”. Any interrupt whose tick count reaches 1 will have its associated routine called and then become disabled.

4.11 Graphic representation of Game Flow

Routine layout for Zork 1. Dotted lines indicate the order of function calls by MAIN-LOOP.

No comments:

Post a Comment