Javascript Developer Intro

Hi all,

Been lurking for a little while. I have rapidly consuming IF information that I can find, and learning Inform 7 in my spare time. I have always been fascinated by Interactive Fiction ever since playing Hitchhikers Guide on an old Apple 2 I got at a garage sale as a kid. I have also been quite engaged with Alternate Reality Games and Transmedia, and different ways of developing and delivering narrative structures through multiple channels while keeping a coherant centralized organization and narrative format.

IF seems to fulfill many of my desires as a means of creating engaging stories with depth, choice, and engagement. I am very interested in expanding the scope of delivery of the medium, as well as the ways narratives are written and delivered for the modern world. I want to expand the scope of narrative beyond the bounds of just one interface and deliver it through websites, twitter, geolocation technologies, email, text message, etc, all the while maintaining a centralized form of scripting and persistence.

I am a Javascript programmer by profession, largely engaged in building and deploying large scale web applications on both client and server. I have little CS background, and have not done any lower level languages such as C. However, since getting interested in IF, it has me looking at the Z-Machine standards, trying to make sense of compiler code, and working to understand the limitations of the VM based architecture.

I am looking to build something which has things such as data persistence via a DB, easy integration to modern javascript libraries and build systems, running JS code alongside and from within IF similar to Vorple, though with tighter integration to JS best practices such as modules, etc. I am also interested in ways to integrate an IF story into a wider multiplayer format similar to a MUD, though which would only become active after a certain point in the single player narrative. Guncho, from what I can tell, did something similar, though its source code is in C, which is a little too much for me to learn at the moment.

Finally, I want to build out a development platform that would allow for the collaborative coding of the games code in realtime with others as a form of modifying the game environment in real time, possibly even while inside the IF universe.

Currently, I am limited by my understanding of how the z-machine-esque compilers/interpreters work, and what I would need to learn/do to build one that has more persistance and JS integration, either into existing code, like Glulxe and inform 7 extensions, or whether I need to consider building something up from scratch.

As far as I can tell, many modern stories are moving to a Twine type format, perhaps for ease of use; however, I am not a huge fan of the hyperlink type games. I love the old school command line, the freedom and experimentation that comes with the NLP type interface, and the immersive engagement it creates.

Any resources, pointers, suggestions, or even better collaborators, would be amazing. I am happy to lend my skills to projects that might help me meet my goals, or collaborate with some other programmers to create an IF platform for the modern web and world. While I have been working as a JS dev for over 5 years now, I am a relative noob to the deeper complexities of assembly, and feel like I am in the midst of giants of the IF software industry. Help and guidance appreciated!



Are you familiar with Parchment?

It’s in javascript.


@bikibo Thanks! Yes, I have had a look at it. From what i can tell, it is mainly a player. It still seems to have many of the limitations of the black-boxed VM.

I have been trying to dive into Quixe, but the compiler code is currently beyond my poor mind to wrap itself around. I have never programmed at that level, so it is rough going. I discovered the z-machine standard, which is slowly helping, but a lot to fill myself in on.

Also looked into Vorple, but it is limited in what it can do, and I am looking for a deeper level of integration into the JS ecosystem and tooling.

1 Like

What do you mean by a “black-boxed” VM? I’d like to think the code for my Z-Machine is pretty accessible. Which lives here btw:


By blackboxed I just mean that the VM is entirely self-contained, with its own internal memory, etc. No persistent storage in a DB, hard to get data out of the VM to be used by other JS applications and scripts, etc.

I am still new to much of the architecture, terminology and how it all fits together, etc. If I have any wrong conclusions or assumptions, I welcome them being clarified so that I come to a better understanding.

Great to meet you @Dannii. I actually have your repo starred and set aside for reference and study, great to be in contact with someone who has built a VM. I have a long way to go to understand what is actually going on. It is my first time looking at code at a low level, working with memory reading/writing, etc.

For a long time, the traditional line was that doing anything parser-y from scratch was a fool’s errand. Many people would come in, enthusiastically announce their intention to work on a custom parser, and then disappear when things got rough.

Recently, though, more people have been sticking. Linus Åkesson has created the Dialog system compiling to Z-machine, which you may be interested in looking into:

Robin Johnson has made a custom parser named Versificator and a follow-up Versificator 2.0 with clickable GUI. He’s won IFComp with this setup.

Finally, there’s a group on here that have figured out how to recreate ZIL, infocom’s original parser. Searching for ZIL should bring up numerous posts.

Of course Parchment, Quixe and Vorple are also the state-of-the-art, but you seem to be well aware of those and their creators.

All of those took quite a lot of work to get done, but they should give you some idea of what’s necessary. Good luck with your work!


@mathbrush Thanks so much! I will definitely be checking those out. If a current compiler works for my needs, I am more than happy to not write anything from scratch. Many of my ideas are quite broad, and I am still in my explore/define phase getting an idea of technologies, standards, etc. I am intrigued by the data structures and mechanics of how things like inform7 work, and how that leads to runable code, and how that code is run. It is just all so foreign to what I know so far (which is also part of the intrigue I think.)

One idea I am toying with is IF mapped over real world locations, event possibly that require physical presence in point in space, and give rise to hidden rooms, doors, objects, etc in those locations. I am quite fond of finding ways to expand the “magic circle” of the game, so to speak, and breach boundaries to find new ways for players to engage in stories with both others and the environment. Also, find means to distribute a work of IF across a few different media channels, but centralized by a terminal type experience, is another inquiry of mine.

Of course, until I know what exists and how it works, I have no idea how to even determine the feasibility of some of my ideas. Plus, understanding the data structures behind the IF games, and how the code turns into the experience, seems pretty crucial.

Thanks again! All the help and resources are very much appreciated!

1 Like

You could also take a look at Fabularium. It is open source: and I understand that it is written in Java.

Fabularium contains a brand new interpreter (Bebek which can play ADRIFT 5 games) also written in Java. Unfortunately, it is only available on Android. I would love to see the Bebek interpreter on more platforms. Ideally, a web application which could run games in a browser and with a decent save-feature.

Since I am not a programmer I don’t know how realistic this is or if it is within your interests.

1 Like

Hi @Parzival. I like your notions about expanding the “magic circle” of the game. I’m tooting my own horn here a bit, but I’ve done some work that may be related to things you’ve thinking about.

I made the Elm Narrative Engine. I’ve been working on it on an off for 3 years. It is web based (written in Elm, which compiles and interfaces with javascript). Like a parser, it tracks a stateful world model, which it evolves based on “rulebooks” using salience and quality based systems. Unlike a parser, it doesn’t do any parsing, rather responds to events. It’s more like the aforementioned Versificator by Robin Johnson than Twine or ChoiceScript.

Most notably, my engine is completely detached from any view. You can make almost any kind of gui you can imagine, and you can trigger the engine from what ever kind of source you want. Also, you can respond to a matched rule in any way that you want.

For example, I’ve hooked it up to a 2d html game engine, and used object collisions to trigger the rules, which then update the game’s stage. You could also trigger it based on location events, or server messages as you mentioned. I have some samples of this versatility along with the source code if you are interested.

I am currently actively developing it, and I am using it for some of my own games, but I’d be happy to see others use it too. If you want to know more, I’m happy to answer questions. Or if it just gives you some ideas or useful patterns, that’s cool too.

@enedev Awesome! Thanks so much for sharing. I will definitely be looking over your source code for some ideas and inspiration. I love that you divorced the engine from a given view. That is definitely along lines I have been thinking, a game engine that tracks a world state, responding to actions and events from multiple channels, and can also respond through various types of actions/state changes.

As an example of my current thinking, if some world state is triggered through player action or actions, it could lead to the uploading of an in game video to youtube. Or a certain object might appear in a textual overlay at a physical geolocation; or tweets from a character controlled twitter account relating to in game events might be triggered.

I have been slowly exploring the concepts of state machines recently, as they are new to me, and loving the possibilities involved for tracking world state, which seems to be the direction you have taken. An engine that tracks world state, especially if it can be persisted in a database of some kind, could be interacted with and changed by one or more players.

I will probably take you up on asking some more questions about it, such as how you have modelled the data in the system, etc. I don’t know elm, so it will be a bit slow going for me to go over the code. If you have any high level architectural diagrams of the major components of the system, that would be super helpful. I do well with big picture strokes when trying to get it all organized.

Again, many thanks for the support and inspiration! It is a fascinating world to get into. Totally different kind of software than anything I have ever build before.

1 Like

Glad to give you inspiration! By the way, making “tweets from a character controlled twitter account” as part of the game experience is a really cool idea.

Making an architectural diagram is a good idea, I should do that. For now, here are a few notes on the design:

World model

The world is a hash map of entity ids (strings). Each entity is an “extensible record”, which means it is a map that can have any key/value pairs, but must have the keys: tags, stats, and links.

“Tags” is a set of strings.
“Stats” is a hash map of strings to integers.
“Links” is a hash map of strings to entity ids (actually entity matchers, see below).

This set up allows for a very simple and flexible design, where authors can control the domain terms of their story. It also is designed to be a part of an Entity Component System pattern (lots of tutorials about this, like here). This is what makes it possible to divorce the engine from the view, and other systems of the complete game. In fact, the Elm Narrative Engine could be considered a single component/system in an ECS based game.


The other half of the engine is the rules system. First off, you can query the world with what I call “entity matchers.” These can check if a specific entity id exists, and can optionally check if that entity has a specific list of properties (tags/stats/links). Alternatively, you can ask if any entity exists that satisfies a list of properties.

These matchers make it possible to get information out of the world model, like all the items in a location, or the player character’s current strength, which is another factor in opening the engine up to its calling code.

Lastly, there are rules, which have an entity matcher to match against the entity id that triggered the interaction, to test if that rule applies. You can also add other constraints about the world as a whole at that time with additional matchers, which must all match for the rule to apply.

Given an entity id, the engine will go through all the rules to find the best match of all that apply. There is a built in way to specify how the world should update, but the rules themselves are extensible records following the ECS pattern, so you can put other information on them relevant to your game, like narration to show, a sound to play, etc. Alternatively, each rule has a unique id, so you could send that as a message to any other system to respond to. Also, you can call this functionality how ever you want as long as you provide an id that will match one of your rules (technically it doesn’t even have to be an entity id, just a string). So you could geotag locations with ids, and send that id when entering that area, for a real world location based game for example.

A final note, this isn’t a novel system, it just was a matter of discovering patterns that worked well, and getting clear about wanting to minimize what the engine controlled. I originally wrote this in Elm, but I have thought of porting it to something that could run in Unity for example. Also, this is fairly similar to various database systems, and I could see this logic/data being centralized on a server, which may be interesting.

I hope that is useful! Happy to hear your thoughts and questions.

1 Like

Interestingly, Anya De Niro created a hypertext series that incorporated twitter. It’s actually the reason I joined twitter. I don’t think it’s still active, but it was pretty cool!

This is the first game:

You might want to look at Quest 6, which is written entirely in JavaScript. It has no editor as yet so is not officially released, but that should not be a problem with your background.

1 Like