Record/Check Room Navigation Path

Hi everyone.

I’m trying to create a game that requires the player to navigate a grid of rooms in the correct path (e.g.: north, north, east, south, east). Creating the rooms and their connections is the easy part, but now I am at a loss on how to record or verify the path the player takes through the rooms.

Does anyone have any ideas on how this could be done in Inform 7? Thanks!


There are a number of ways of doing this. Do you want to store the entire path, force the exact path the player takes (without deviations), or simply that the player has reached the end of the path?

Thanks for responding so quickly! I’d be happy with knowing if the player has taken the exact path I’ve already decided on (hard coded into story). That is, the exact series of rooms from start of play to end of play.

Not a problem, it’s instructive for me as well. Anyway, I suspect you’ll be wanting to review this example, in which an exact path is stored in a list.

This seems to work, although you should be aware that any deviation is going to cause issues, and it doesn’t reset, so you’ll need tweakage. There are a lot of ways of doing this, and this is probably the least sophisticated, so if you find you need more, there are other options.

[code]“The Path Not Taken” by Gravel

The Proper Path is a list of directions that varies. The Proper Path is usually {north, north, east, east}. [The exact path you want the player to follow.]
The Chosen Path is a list of directions that varies. [The exact path the player does follow.]

The Maze Entrance is a room.
Twisty Maze is north of the Maze Entrance.
Turny Maze is north of Twisty Maze.
Topsy Maze is east of Turny Maze.
Turvy Maze is east of Topsy Maze.

After going:
add the noun to the Chosen Path. [This will always be a direction, and will only trigger for successful travel - if you want to track where the player tries to go, this should be a before rule instead.]

Every turn: [Just basic testing demo]
say “Your chosen path is [Chosen Path].”;
if Chosen Path is the Proper Path:
end the game saying “You have chosen wisely.”;

test me with “n / n / e / e”.[/code]

That works for my needs perfectly. Thanks gravel!

While not -exactly- what you asked for ( this template doesn’t record the outcome so much as it works as a permission/obstruction system ), here’s a variant using the classic Legend Of Zelda forest ‘maze’ as an example:

[code]The Graveyard Entrance is a room. The Forest is east. a room called Forest Clearing is east. The player is here. The Forest is north of the forest and west of the Forest.

The Forest has a number called the golden path. The golden path of the Forest is 1.

Before going a direction ( called the path chosen ) while in the Forest:
Let N be the golden path of the Forest;
if the path chosen is ( the correct direction in row N of the Table of Right Pathways ):
increase the golden path of the Forest by 1;
now the ( correct connection in row N of the Table of Right Pathways ) is mapped west of the Forest;
now the golden path of the Forest is 1;
if N is 4:
now the golden path of the Forest is 1.

Before going to the Forest when the location is the Graveyard Entrance:
now the Forest is mapped west of the Forest;
now the golden path of the Forest is 1.

Table 1.1 - Right Pathways
correct direction correct connection
North Forest
West Forest
South Forest
West Graveyard Entrance[/code]

It’s designed as shown mostly just to build a fake pathway that keeps reusing the same room repeatedly, but you could easily modify it to use multiple rooms, and you could put as many lines as you wanted in the table to make dozens of rooms line up in an exacting order.

( I’m sorry to have posted this long after it would be useful. I did have almost 90% of the code ready about 4 hours ago when life and stuff sort of got in the way. Here it is in any case. :stuck_out_tongue: )