Automap by Mark Tilford


Automap will watch what rooms the player has visited and create a Beyond Zork style automap.

Kinds: Mappable Room. All rooms which are to show on the map must be of this kind.

By default, rooms will be placed one unit away in the appropriate direction. If the path should be longer, you can manually set the distance.

It is the responsibility of the author to make the map has a consistent geography and that no two rooms overlap.

Activities:

- The "Automap work" is activity is being handled while the program is attempting to explore a room or draw the map (that is, the times when it might perform the "which room is (direction) from (room)" decision). It is provided if you need to have anything work differently during such a test.

Use options:

- Use automap manual display: The program will not display the map to the status line on its own.

- Use automap manual exploration: The program will not add rooms to the map unless you explicitly run the "(room) is explored" decision.

- Use automap hide paths through closed doors: The program will not add paths that go through closed doors.

- Use automap static allocation: Causes a glulx game to allocate memory for the automap at compile time. Reduces flexibility, but allows the game to run on more interpreters. (Automatically set when compiling to zcode.)

- Use automap reserved area of at least N: Sets the amount of memory the game will use for drawing the map. Must be at least (map rows) * (map columns). This option is ignored when compiling to glulx, unless the "use automap static allocation" option is set.

- Use automap visible background: Spaces that would ordinarily be blank will be shown as periods. Meant for experimenting with the size of the map while testing and is not meant for release.

New source code syntax:

decision: "(mappable room) is placed (number) and (number) from (mappable room)": If the player has visited both rooms, it will attempt to arrange the map so that they will appear in the given relative positions. Returns yes unless doing so creates an inconsistency. It will not be necessary to use this decision in your own code unless you want to have rooms that would not ordinarily be on the same map region together. (For example, if a closet is connected to the main room by in / out, this would put it on the map with the rest of the rooms.)

decision: "(room) is explored": Attempts to connect (room) with any adjacent rooms. It probably will not be necessary to use this unless you want to add rooms the player hasn't visited, or you are using the manual exploration option. Returns no if doing so creates any inconsistencies, and yes otherwise.

phrase: "explore (room)" / "remap (room)": Attempt to add the room to the automap. Prints an error if there are any problems. Again, it probably will not be necessary to use this unless you want to add rooms the player hasn't visited, or you are using the manual exploration option.

phrase: "unmap (mappable room)": Removes the room from the automap. Will be needed if you want to change its position relative to other rooms.

phrase: "fill status bar with (selected table - a table-name) and map": Will print the calculated automap. Should only be necessary if you are using the manual display option.

phrase: "reserve automap memory of (number) rows by (number) cols": Sets the size of the displayed map. Must be called for any map to display. May be changed at any time. (Maps will center better if the height and width are 1 more than a multiple of 4: 1, 5, 9, 13, 17,...)

phrase: "reserve automap memory of (number) rows": Sets the size of displayed map. Width is the current width of the status line. If using static allocation, and this would require more memory than is allocated, width is trimmed to what will fit. (Maps will center better if the height and width are 1 more than a multiple of 4: 1, 5, 9, 13, 17,...)

New in-game commands:

- "zoom in": Shows the map so that rooms have 3x3 grids.

- "zoom out": Shows the map so that rooms have 1x1 grids. (the default)

- "zoom away": Removes the map entirely.

- "zoom": Rotates through the various zoom modes.

To set the zoom manually, change the current zoom variable to map zoomed in, map zoomed out, or map absent.

- "map automatic": Try to use the font 3 characters. If the interpreter does not support them, convert down to ASCII characters.

- "map fancy": Force using the font 3 characters, whether the interpreter supports them or not.

- "map plain": Convert down to ASCII characters. Don't even try to use font 3. (the default)

If the game is run on a buggy interpreter, using the command "gargoyle bug workaround" should prevent problems.

- "map view" (not for release): shows information

Thanks to Jesse McGrew and Mike Talbert for help with overriding decisions. Thanks to Cristoph Ender and Andrew Plotkin for help with Unicode. Thanks to Andrew Plotkin and Jesse McGrew for help with joining I6 and I7. Thanks to S. John Ross for testing and feedback. Thanks to Aaron Reed for feedback and a minimal example. Lots and lots of thanks to Peter Pears for heavy testing and feedback. Erik Temple prepared version 4 for submission to the extensions library.

Section: 6L02 Compatibility Update

This extension differs from the author's original version: it has been modified for compatibility with version 6L02 of Inform. The latest version of this extension can be found at <https://github.com/i7/extensions>.

This extension is released under the Creative Commons Attribution licence. Bug reports, feature requests or questions should be made at <https://github.com/i7/extensions/issues>.

Example: * "The Test" by Aaron Reed - A minimal test. Note that, as of late October 2010, this example will crash in some interpreters (such as Zoom and the IDE interpreter on Mac OS X) under Glulx. Include the "automap static allocation" use option to prevent this kind of crash.

"Test" by Aaron.

Include Automap by Mark Tilford.

Stage is west of Wings and north of Dressing Room. Booth is northwest of Wings. Closet is east of Wings. It is unmappable.

Example: ** The Demonstration - A simple demonstration.

"The demonstration" by Mark Tilford.

Include Automap by Mark Tilford.
Use automap hide paths through closed doors.
Use automap reserved area of at least 400.
Include Basic Hyperlinks by Emily Short.
Use automap hyperlinks.

When play begins: now current zoom is map zoomed in.

The heavy door is south of the western hall and north of the office. It is a door.
The southern hall is southeast of western hall and southwest of eastern hall. The eastern hall is east of western hall.
The heavy door is a door. It is south of the western hall and north of the office.

Fooing is an action applying to nothing. Understand "foo" as fooing.

Before fooing when the player is in eastern hall or the player is in western hall:
     say "To make a longer path, the distance must be declared both ways."
To decide what number is the distance (d - east) from (r - western hall): decide on 2.
To decide what number is the distance (d - west) from (r - eastern hall): decide on 2.

The western balcony is up from western hall and west from central balcony.
The eastern balcony is east from central balcony and up from eastern hall.

Outside Building is a mappable room. It is west from western balcony.

Before fooing when the player is in western balcony or the player is in eastern balcony:
     say "By default, rooms connected with up / down / in / out are not placed on the same map. If you want to put them on the same map, you can position them manually."

Before constructing the status line:
     unless western balcony is placed 0 and -1 from western hall, say "*** Error placing west balcony ***";
     unless eastern balcony is placed 0 and -1 from eastern hall, say "*** Error placing east balcony ***";
     unless upstairs closet is placed -1 and 0 from upstairs office, say "*** Error placing upstairs closet ***".

Upstairs office is north of western balcony.
Upstairs closet is inside from upstairs office.

Stupid room is a mappable room. It is east from upstairs office.

Alpha room is east of stupid room.
Beta room is north of alpha room and northeast of stupid room.
Gamma room is west of beta room and northwest of alpha room and north of stupid room.
Joe's room is southeast of beta room.
Fred's room is northeast of beta room and north of Joe's room.
Jane's room is east of beta room and southeast of fred's room and northeast of Joe's room.
To decide what number is the distance (d - east) from (r - beta room): decide on 2.
To decide what number is the distance (d - west) from (r - jane's room): decide on 2.
To decide what number is the distance (d - north) from (r - joe's room): decide on 2.
To decide what number is the distance (d - south) from (r - fred's room): decide on 2.

Before fooing in elevator:
     say "If you want to move a room on the map, you'll have to unmap it first."

The elevator is a mappable room. The elevator can be high or low. It is low.
The elevator is east of eastern hall.
The button is in the elevator. It is fixed in place.
Instead of pushing the button:
     say "The doors shut; the elevator shakes briefly, then the doors open again.";
     unmap the elevator;
     If the elevator is low begin;
         now the elevator is high;
         change the east exit of eastern hall to nothing;
         change the east exit of eastern balcony to elevator;
         change the west exit of elevator to eastern balcony;
     otherwise;
         now the elevator is low;
         change the east exit of eastern hall to elevator;
         change the east exit of eastern balcony to nothing;
         change the west exit of elevator to eastern hall;
     end if.

before fooing when the player is in western balcony or the player is in outside building:
     say "If you want to split rooms into separate map regions despite them being reachable from each other by compass points, you can override the decision so that it has a different value while working with the automap than when making ordinary movement."

Phony Room is an unmappable room. It is west of office and southwest of western hall.

To decide what room is the room (dir - west) from (room - western balcony):
     if handling the automap work activity, decide on Phony Room.

To decide what room is the room (dir - east) from (room - outside building):
     if handling the automap work activity, decide on Phony Room.

To decide what number is the distance (dir - west) from (room - western balcony): decide on 3.

before fooing when the player is in western balcony or the player is in eastern balcony:
     say "(Current versions of Inform do not go through the decision mechanism when responding to the player's compass movements, so the 'if handling the automap work activity' check may not be necessary. Something like 'decide on nothing / nowhere' end should theoretically allow hiding a passage completely, but all I got were syntax errors.)[line break]"

before fooing the first time:
     say "You must set the displayed size of the map before it is displayed. This can be changed at any time not during automap work.[line break] To fix the size at the start, use something like 'When play begins: Reserve automap memory of 13 rows by 17 cols;'.[line break] Omitting the columns will have it allocate memory to fill the width of the screen, but you must readjust each time the status line is rebuilt.[line break] In Glulx games, it will automatically allocate memory as needed. In Zcode games, you must reserve that memory in advance: Use automap reserved area of at least 400. (It's okay to put such a line in a Glulx game; it will be ignored.)[line break] In ZCode mode, you must print at least as many blank lines as your map is high so that the text will start out below the automap.[line break] Map sizes are in characters; a room is 1 character square in zoomed out mode, 3 characters square in zoomed in mode."

Section 99Z (for Z-machine only)

When play begins: say "[map height blank lines]"

Section 1

before fooing the first time: say "If you want something other than the usual line above your map, you'll need to build the status line yourself.[line break]"

The first for constructing the status line rule:
     reserve automap memory of 13 rows;
     fill status bar with table of mostly ordinary status and map.

Table of Mostly Ordinary Status
left     central     right
"[location]"     ""     "[score]/[turn count]"
"---"     "---"     "---"

Section 98 (for use with Basic Hyperlinks by Emily Short)

Current autowalk destination is a room that varies. Autowalk destination set is a truth state that varies.

autowalking is an action applying to one topic. Understand "autowalk to [text]" as autowalking.

Carry out autowalking:
     if autowalk destination set is true begin;
         now autowalk destination set is false;
         try hyperlink moving to room current autowalk destination;
     otherwise;
         say "(Autowalk is meant to be generated by hyperlinks, not typed directly.)";
     end if.

The first clicking hyperlink rule:
     if current link number codes a glulx object begin;
         change current autowalk destination to glulx equivalent of current link number;
         now autowalk destination set is true;
         now glulx replacement command is "autowalk to [current autowalk destination]";
         rule succeeds;
     end if;