Z-machine - maps, inventory, and miscellaneous

So, I’ve been playing around with my z-machine interpreter’s mapping and it has evolved into a more general system that can display the map piecemeal as you explore, inventory, health, treasures collected, and almost any other in-game stat or condition. Currently all the additional visualizations are in a single window, but that’s probably not ideal. I was thinking maybe one window for the map, and one for everything else? It works similarly to the BBC’s enhanced Hitchhiker’s but can work for any zcode game without any game-specific changes to the interpreter.

3 Likes

Now I’m thinking maybe map, inventory, and status windows?

So I’m hoping to stand up a small test soon. Anyone have recommendations of what they’d like to see in an “enhanced” Zork I ?

Does it auto-generate the map or is it a pre-designed layout that reveals bit by bit?

I have failed to make any auto-generate map layout that looks nice. You can get something sort-of working, but there’s usually a bit of the map that’s very poor.

Not auto-generated. It requires a custom map for each game. It can reveal each room or path as it is entered or traversed. They can visually look like anything though - limited by my horrendous art skills of course. It can also display custom graphics for any object in the game and for special conditions like a health bar, growing pile of treasure for increasing score, etc. For example for Zork I can have a trophy case that shows each treasure as it is placed in the case.

1 Like

The most interesting point on custom (auto)map is how to interface the map and story, esp. with large maps. The simplest is setting the visited flag in both story and map when enering the location for the first time, but this came with a price of two set of flags, one for the story and other for the map, plus ensuring that the two set are in sync.
Another is using the same story flag for the map, but this came with a price in speed, the map display routine needing to collect the various visited flags when displaying (and the routine can be a complex one)

so, the classical computing balance, running speed vs. memory footprint: one solution favores execution speed, the other favores memory saving. There’s other alternatives ?

Best regards from Italy,
dott. Piergiorgio.

The resources needed to display graphical maps or other resources dwarfs any runtime or memory cost of location/item flags.

2 Likes

Also, isn’t all the mapping done outside of the game (the interpreter side) and don’t interfere with the games internal memory allocation?

Yes, my interpreter core exposes z-machine internals in such a way that the UI can cue off virtually anything to manipulate a map or other visuals. I threw together a quick demo (pardon the horrible graphics). To support a game only a new map file is needed.
map

1 Like

So your interpreter can ascertain visited locations, objects carried and maybe the locations of things?

If so, this is great. I was lead to believe this wasn’t something that could be done reliably. But i really hope it can.

And if so, more interpreters should do this. Or at least provide API to such metadata.

Your project sounds really good.

It’s completely reliable. It doesn’t use text names, but internal ids. It can distinguish all the identical rooms in a maze, or show multiple rooms as one if a game uses two locations to represent a single room.
I can reveal locations and paths, display inventory, show the player’s location, track NPCs, show a health bar, show items on the map, or just about anything else relevant to a game. The map supports zooming and auto-panning to the player location. All that’s needed to make a custom display for any game is inkscape. The interpreter handles everything else.

Making a custom display for a game requires a fair bit of knowledge about the game and its internals (dumpable from the interpreter). But really it’s not very hard.

1 Like

With an asterisk that the interpreter can do this for specific known games. It needs to know the internal object ID number of each room, for example, to connect them to squares on the map.

Nope - everything the interpreter needs is in the map. They don’t have to be squares either. :slight_smile:

Wait, how do you handle that without a mapping from room ID numbers to map squares (or whatever shapes)?

Magic!

Well, not really. I use svg files for maps. Inkscape lets you define layers with arbitrary ids. I created a sort of shorthand for the interpreter to read from the file so it knows what variables, objects, or memory locations to track and maps those to specific layers of the image. So when a map is loaded it tells the interpreter what variables and objects to watch. The interpreter map data is updated whenever one of those tracked quantities changes and it updates the visibility of the layers that are relevant.
Creating a map is just building a multi-layer svg with the appropriate id names.

2 Likes

Ah, nice! So it’s all stored in the map file? That seems like a good method; hypothetically a tool could take the debug info from the compiler and update the map automatically every time an author rebuilds it.

Yep.

Edit: In fact there’s a layer of indirection in the map. You can give layers intellgible names like “egg_now_4” and if you also define “egg-op87” in another place, then whenever object 87 has object 4 as a parent the image is visible.

I’m still adding some features, like negative conditions and gt, lt, etc.

Another edit: I changed the example here to use what I have in the demo above (object 87 is the egg in Zork I release 88, and 4 is the player). The interpreter knows to track the parent of object 87 based on the info in the map. Whenever the value changes, any “egg” layers get their visibility updated. In the example above, if the value is 4, then the egg is in the player’s inventory and it shows up on the map. :slight_smile:

1 Like

Right now the biggest limitation is if you want to display a single image (like a brass lantern, or a robot in Suspended) at every possible location in the game, it bloats the svg because you need a copy at each location, but I’m working on a system to allow dynamic translation of a single image to arbitrary locations.

1 Like

I did something similar a few years ago, for Glulx, by inspecting Quixe’s memory (inspired by zarf’s Hadean Lands which also did that).
I also used an SVG with IDs (the name of the room) and attributes mapped to Inform’s properties.
It also handles doors so you can draw open/closed/locked doors.

There’s also a version which extracts the inventory and one where the map is drawn in Tiled & rendered with Phaser but I’ve just checked it and it’s broken, I need to fix it.
The only downside is that it needs the gameinfo.dbg to map names to internal IDs but it could be made to work directly with the internal IDs.

Demos:
SVG
Inventory
The first one is in French, but you can try:

ouvrir coffre. prendre clef. nord. 
ouvrir fenetre avec clef. est. 
ouest. sud. sud. x tapis. descendre.
2 Likes

I fixed the Tiled one: Tiled demo

2 Likes