Z-Machine Tools as Future Narrative Middleware?

During his Narrascope 2019 talk Mr. Nelson mentioned the possibility of an open-sourced Inform 7 being modified to function as a game’s narrative middleware.

But what if Inform could actually be used directly to provide final implementations inside games? In other words, as a middleware component in, for example, Unity?

While we wait for that day I’d like to ask those who are more familiar with the technical details of the other Z-Machine programming tools —ZIL, Inform 6, Dialog—if any of them could be modified to function like the narrative middleware Mr. Nelson mentioned.

I think a viable candidate would have to fulfill two criteria to be considered:

  • Its source code would have to be publicly available
  • Its licensing would have to allow modification for the intended purpose

Does anyone have more information about these two criteria as they relate to ZIL, Inform 6, and Dialog?

1 Like

This is already quite possible, whether that’s through running the IF interpreter in a separate process, or embedding it more directly. Graham’s talk was more about the advantages that exposing the Inform model directly to code could bring, rather than using text as the interchange format (and then needing to do text processing in the end application.) But if you wanted to, you could already do more of that now, particularly with Glulx and its custom opcodes etc. You could implement GraphQL to query the world model within Glulx and Inform for example. But it would probably be more work than just doing it through text processing. :wink:


To say this in more detail:

Graham was talking about separating the high-level Inform 7 language, with its rule-based programming model, from the low-level I6 language and VMs that it currently compiles to. And then adapting I7 to some Unity middleware.

Using the Z-machine or Inform 6 as middleware is pretty much the reverse of that. It’s keeping the bit that the talk imagines throwing away.

It’s certainly possible to do it. You’d just need a Z-machine interpreter written in C#, which I think exists, and then use Unity as its display layer. But there’s not a lot of leverage in this beyond the specific goal of inserting a parser-based text game into a Unity game. I6 is not a good choice for controlling any other kind of game.

(Graham’s hypothesis is that I7 is a good choice. I have some faith in this idea, but then I’m biased…)


uhm… Unity is a major 3D game engine; Inform 7 is for 1D (my definition of text adventures), or 2D static with glulx, games; I can call this an overshoot ?

OTOH, Unity, with all his power, can never handle the most powerful image renderer (the human imagination) whose IS the actual graphic renderer of text adventures.

So, feel free to colour me highly skeptical…

Best regards from Italy,
dott. Piergiorgio

Well Inkle’s games are produced with Unity, but they use their own text based Ink IF system to implement the game rules (and perhaps dialog etc too?) In the same way you could use any other IF system underneath a Unity interface. So no, it’s not an overshoot or anything.

The original fyrevm was written in C# and is available on my GitHub. I believe a game publisher tried to integrate it with Unity, but ran into performance problems and abandoned it. But I also think they were trying to run a very large oddly built story file. A standard story probably wouldn’t be a big deal.

Many Unity/Unreal games have a narrative/dialogue middleware library. Some of them use Ink or Yarnspinner for this; others have a custom component. You can imagine using one of I7’s dialogue extensions in this way. Is I7 as good for dialogue as Ink? Depends on what the author is comfortable with, but maybe. It’s not a silly idea.

Kerkerkruip is an example of leveraging I7’s rule model for a different kind of game. It’s not dialogue, but it’s still character interaction with lots of special cases and unique outcomes. (That’s what I7 is best at.)

The alchemy model in Hadean Lands is another example. If I were working on a graphical RPG with alchemy, I’m not sure I7 would be my first pick – but if it were an option, I’d consider it.

To make sure I understand

Currently, closed-sourced Inform 7 uses the Inform 6 compiler to create Z-Code that can be run in a Z-Machine interpreter (intentionally leaving out Glulx but I know Inform 7 can also output that as well).

An open-sourced Inform 7 could be modified to produce C# C-Code which could be run in Unity, providing someone writes a C-Machine, which would be able to access the Inform 7 data structures as a bridge to the Unity environment.

Since the compiler source code for the ZIL, Dialog, and Inform 6 are available, each could be modified to produce Unity-compatible C-Code.

However, by doing so, you would give up Inform 7’s rule-based, declarative programming style.

1 Like

Guncho essentially used Inform 7 as middleware, although the interface it presented to users was designed to feel like playing the Inform game directly.

A modified version of the Standard Rules was used to implement a protocol on top of the usual text I/O, passing events and information about the game state back and forth between the server and the Z-machine or Glulx VM. Player input was tagged with a player ID before being passed in, and the Report rules were run multiple times to describe the action from each other player’s perspective.