Nonadecimal Creative’s primary goal is procedural narrative: an engine that can generate dynamic stories that adapt to challenge players’ successes and build new stories from their failures. Because it’s such a colossal undertaking requiring a lot of research and development, this project frequently ends up sidelined while smaller, more focused games are developed and released to fund the company’s operation. Here’s a little background on past work that inspired this goal, the framework for future work, and the present work struggling to make progress.
A brief career in swarm robotics created a passion for autonomous agents capable of working cooperatively and competitively. While perfecting machine vision and autonomous navigation in unfamiliar environments occupied my work week, it left a lot of unresolved ideas about how a machine could understand contextual relationships in a human-dominated world and how it could develop long-term plans to achieve its objectives despite obstacles. I also spent some time investigating the fastest way for a group to search an area for a target. In 2016 I revisited these concepts while designing challenging AI opponents for my cellular automata RTS, Automata Empire, simultaneously pushing the limits of how many thousands of swarming units I could simulate on-screen.
Meanwhile, writing stories and narrative puzzles for The Matrix Online MMO inspired new approaches to storytelling. While the stories began from static outlines, the input from players interacting with the stories’ characters (also played by me) forced additional twists and turns into the narrative: red herrings in response to their wild theories, new story branches to accommodate their unexpected insights, ideological conflicts to divide the players into puzzle-solving alliances beyond their gameplay factions. Responding to the players’ conversational cues and interrogations in real-time meant constructing complex decision trees in advance to dictate how my characters would respond and which cues would trigger changes in behavior or the release of a new clue. In essence, a gamified social interaction system. This experience transformed my impression of storytelling into a organic process where the audience was an active participant that shaped the course of the story.
During this time I also worked on a handful of mathematical models, simulations intended to recreate the real world in data. A model to optimize the location of new natural gas power plants, a model to optimize the locations of a network of cell phone towers for customer service or for profit. Even a model to quickly generate scientifically accurate planets derived from an inputted gravity or surface temperature for sci fi worldbuilding.
The trajectories of all these experiences lead to a contextual model of the world that an autonomous agent can solve to achieve its emotion-driven goals: a procedural narrative engine.
What would it take to make such a thing?
1) Knowledge Representation
The characters need a way to comprehend the world they inhabit. A language to describe how objects in the world are contextually related. For example:
- All objects need an energy source to complete tasks.
- All animals eat plants and animals as an energy source.
- A chef is employed by a restaurant to cook plants and animals.
- Employment is an exchange of completed tasks for money.
And so on. After looking at existing crowdsourced semantic networks like ConceptNet, it seems that a game would need its own much smaller, hand-crafted set of contextual data that is specifically relevant to its game world and mechanics. Building a framework for creating, editing, and applying this data is currently the top priority for the narrative engine.
2) Procedural World Generation
Utilizing the contextual data that defines every object that can exist in the game world, the next step is to generate the world. Procedural world generation is a familiar concept in games right now, typically in the form of randomly generated dungeons and cities. Architecture in the real world is a balance between function and aesthetic, each with their own set of rules. I’d like to codify these rules into a system that can design building layouts according to their function. For instance, hotels and hospitals share certain design elements: a spacious and aesthetically-oriented lobby attached to hallways that lead to many small identical, functionally-designed rooms. Restaurants, on the other hand, are usually one or more large open aesthetic rooms built around a smaller, functional kitchen room. However, some hotels and hospitals may even contain a restaurant template subset within themselves!
Armed with a functional knowledge representation system, the world generation should be capable of populating hotels, hospitals, and restaurants with the appropriate objects needed for each of their functions, as well as supplying the logic for how characters would behave in that setting and use the tools supplied. Scaling up further, it would need to understand the context of a city: the distinction between residential and business areas, the constraints of urban density and transportation.
3) Long-Term Planning
Given the contextual relationships between objects placed in the world, characters need to make plans to achieve their objectives. That means knowing which tools to use on which objects, knowing where to go to find things, knowing who to talk to. Taking into account the current world state, the planner would derive a series of ordered steps whose outcome would result in the desired world state. This gives NPCs the ability to turn their goals into actions and adapt to failures. This could manifest as the ability to gather the tools and accomplices necessary to execute a heist as well as giving NPC antagonists a competitive strategic advantage when trying to thwart human players. More in-depth study of situation calculus, GOLOG, and more recent advancements required here.
4) Emotional Behavior
Given autonomous agents that understand how to manipulate their environments to achieve their goals, they need a reason to do things! Intrinsic motivation comes from our emotions. We seek more satisfaction, we try to minimize stress, we avoid harm. The final component is an emotional model that allows NPCs to remember things that have happened to them in a way that will influence their future behavior. Using this model in a game would allow the player to interact with NPCs socially, whether as a confidant, salesperson, politician, or con man. It provides a strong foundation for non-violent objectives within the game.
5) Narrative Constraints and Calls to Action
At this point you have a fully functional simulation of the world. You can interact with the system, causing perturbations that ripple through the lives of the NPCs. But just as the NPCs need their own source of motivation, the player does too! In the absence of scripted quests, the engine needs to generate conflict relevant to the protagonist’s actions. This means creating appropriate crises for the NPCs you associate with, generating competent antagonists to challenge you, reassembling permutations of genre tropes.
An overlooked difficulty here is that the player also needs to be able to understand why NPCs are doing the things they do. While the engine knows the emotional states driving every NPC’s action and the web of connections between characters, if the players aren’t given enough information to infer those connections themselves, they will assume events are happening randomly or, even worse, feel like the system is cheating. In order to feel like they’re in control of their personal story, the player needs to be well informed. Determining what information the player needs to have agency is a tricky planning problem in itself!
6) Natural Language Text Generation
With all this conflict happening in the form of ad hoc schemes devised by emotion-driven NPCs, they’re going to desperately need a way to tell you about it and ask you to sort it all out. That means a way of verbally combining the data from the knowledge representation system with the long-term plan, adding emotional valence from the behavioral model, and making sure the whole thing makes grammatical sense to the reader. Generating conversations and expository details will be essential to solving the player knowledge problem.
Obviously this is a complicated, multi-year project. There are a number of incredibly intelligent people working hard to advance each one of the fields mentioned above, much less trying to combine all of them. I first started researching the project in 2011, trying to figure out how all the components fit together and the current state of academic research for each. It’s taken a few years to build a company, make a few games to build experience, and become self-employed full-time in order to tackle larger projects.
Along the way, I have done my best to make my games small enough in scope to finish while also teaching me skills that are useful to the long-term goal. I’ve made some progress on the emotional behavior model, plot generation, and text generation. Here’s the state of it.
I had the strongest ideas for the emotional behavior model and it wasn’t directly dependent on the other systems, so I was able to engineer something for reacting to stimuli and storing memories with specific emotional valences. While some of the methods I studied were focused on creating realistic facsimiles of the human brain with simulated adrenaline/dopamine/serotonin, I opted for something much simpler that can still emulate human reactions. I’m not ready to share the specifics until everything else is in place, but here’s a diagram that shows how nicely symmetrical it is. Ooooh.
Unfortunately, it’s not much use on its own. In 2015, I made a simple text sandbox of five enumerated Victorian aristocrats and their servants to play with this idea but it wasn’t very sophisticated and didn’t seem worth expanding further when there were more valuable games to make.
In 2015 I also started working on a simple cyberpunk plot generator prototype for my friend’s game, Black Ice. Because it’s a cyberpunk hacking game set in cyberspace, it simplifies the problem by keeping social interactions limited to emails, eliminating the need for conversational dialog trees. The emails are easily generated by conditionally combining sentence templates based on the NPCs relationship to you and filling in the appropriate data “mad libs style”. The first attempt involved working backwards from a generated final objective (blue line) and adding prerequisites and sub-objectives until the plot tree had reached a sufficient depth. Some prerequisites were added already complete (green lines) to signify resources you already have or that would be provided by your employer. Incomplete prerequisites (red lines) generate a nested objective (white lines) underneath.
In the above example you’re hired to steal an assassin drone from ALL Security. Your employer has determined that an imprisoned ALL Security employee, Kabir Parsekar, knows the access codes to activate the drone. But first you need to steal a Shometsu XL assault drone and use it to break through a weak spot in QDF Industrial defenses (discovered thanks to some surveillance) to get the biometric keys your team will need to breach ALL Security’s holding facility and rescue Kabir. If you succeed at all 4 events, you obtain the assassin drone and receive payment.
Unfortunately, despite this method being functionally sound, its output is too rigid and linear for my liking. It produces good heist stories where you have to gather an unlikely crew of human and machine accomplices and steal the necessary keys and tools to complete the job, but over the course of many of these stories would begin to feel as repetitive as the scripted quests it’s supposed to replace. This method also doesn’t work well with branching after the player makes a choice to diverge from the original plan or hits a fail state that needs additional branches. I began working on a new framework that would allow generating plot trees forward or backward from any point, but have begun wishing I had a knowledge representation system to make this process easier and eliminate the need for excessive hard-coding.
If done properly, the system should allow a player to subvert the original plan, either by turning on their employer when a better opportunity presents itself or even turning both parties and their corporate overlords against each other in appropriately cyberpunk fashion. We’ll see if I’m able to add knowledge representation to the mix or complete something sufficiently dynamic without it. Even if this extra layer of choice never makes it into the final release of Black Ice, it’ll have been a good learning experience.
Ultimately, there’s a lot of work remaining to complete the goal of Moriarty in the holodeck. I’ll continue updating this page as things change.
If you’re interested in these topics too, whether approaching it from the angle of robotics or videogames or storytelling or AI, it’d be great to talk to you. You can reach me at @Nonadecimal. I love hearing about the work others are doing in this field and seeing their progress tackling these weighty problems.