Archive

Archive for October, 2020

The Problems with Paths

Navigation is a fairly straightforward process in Interactive Fiction, and it can be implemented in a number of ways, depending on the authoring system you are using. With Inform 7, which is a powerful yet relatively simple plain-English system, you can create a path between two rooms very easily;


The Library is room
The Parlor is south of the Library.

The code above immediately creates a room/location called Library. The a second room is created in a relative position, south, from the first room, and the second room is call Parlor. Since Inform 7 manages the room relationships, when executing the above snippet will have you “starting” in the Library, and you will be able to go south into the Parlor, and then north again back into the Library simply by typing “south” and then “north” in the automatically provided prompts.

This is one of the advantages in using Inform 7 when creating your game, as the system manages all location relationships (among other things). In this way you can create a fairly complex geographical space which to explore, without having to do a lot of work setting up variables, arrays, conditional statements and so on.

Unfortunately, this kind of high-level ease comes at the price of less granular control and flexibility over what can be done in the program. One of the functions that Inform 7 does not provide (without creating extensions) is the ability to think of paths between map locations as “locations” themselves, with their own descriptions and attributes. Additionally, paths should have different descriptions based on the direction of travel. Using an typical programming language this can be implemented straightforwardly through the use of arrays.

In order to add this and other functionally to the project, I decided to move the program from Inform 7 to the LiveCode language (an open source version is available). I selected LiveCode because of it’s robust built-in text processing functionality, which means the parser that I build can easily identify words and phrases without having to do any character counting. LiveCode is also loosely typed, so I can deal with variables much more easily.

Using LiveCode, I’m able to conceptualize paths as locations, yet I’m able to have the program “pass through” without stopping or identifying the paths as specific places to stop or break the action. This means I can leave one building to cross the street to the entrance of another building, and action can take place in the street along the way. Consider the mini-map below.

There are two locations here. Location 37 which is west of Location 19. There is a path between the two, which you may assume is bi-directional. So if I were in Location 37 and typed “east” as my command, I would be taken to Location 19. It might look something like this in my display:


You are in Location 37.

>> west

You are in Location 19.

Certainly I could change the description of Location 19 to include a little bit of travel observation, such as:


You are in Location 37.

>> west

You walk across the rough grass to Location 19.

But this introduces more programming complexity. First, what if I could enter Location 19 from the north and the south as well? At that point, adding the path description into the location description would not make sense.

Instead, in LiveCode I am able to create another array that keeps track of path descriptions and other attributes. I can use the format:

aPath[x, y, z]

Where aPath is the array name, the variable x is the initial location and the variable y is the destination location. The variable z can be used for a number of attributes such as the path description, path status (if there is an open or closed door), etc. For example:

aPath[37, 19, 0]

would signify the path description when moving from Location 37 to Location 19, and reversing the direction would yield a different description:

aPath [19, 37, 0]

There is quite a bit more that can be accomplished with this separate path designation, including allowing players to find or leave objects on paths, encounter non-player characters, experience different weather conditions, and find barrier puzzles that need to be solved. From my point of view, it’s much easier to manage this through LiveCode (or any other high-level language) rather than using Inform 7, which makes certain assumptions as to how Interactive Fiction should work.