Anansi: Storylets and Character Simulation

Technologies C#, Unity, Ink
Project Status Inactive
My Role Tools Developer

Anansi is an interactive storytelling tool for creating storylet-driven procedural narrative games in Unity. It combines the Ink narrative scripting language, a query language, and custom C# code to add storylet support to Ink. If you’re not familiar with storylets, they are an approach to narrative design in games in which story content is divided into independent chunks that players can experience in varying orders. Emily Short has a great blog post explaining this further. An undergraduate researcher and I started developing Anansi in the summer of 2023. At the time, Anansi was named Calypso.

At the time of writing, to my knowledge, Anasi has only been used in one project. I used Anansi as the narrative management system in an NSF-funded educational game. The process of developing that game taught me valuable lessons about game development and designing experimental tools. These lessons included the importance of proper prototyping/vertical slices, the need for codeless debugging tools, and the utility of proper design patterns/examples.

Project Motivation and design problem

This project explored the following design problem: “How do you build a narrative system that allows a game designer to leverage the emergent potential of social simulation while providing sufficient controls to produce a coherent narrative experience?”

I wanted to build Anansi to provide a way to tell structured stories using the emergent social scenarios generated by the character simulations I built. My simulations were good at producing interesting outcomes, such as generational family feuds, power struggles, and alliances. However, I did not have a good way of presenting this information in a playable experience. I knew storylets were the best solution for storytelling in simulation games, but I didn’t have a framework or toolkit to dynamically cast characters into storylets based on preconditions. There were existing systems like Lume, but I wanted to see if I could take an existing, off-the-shelf narrative scripting language and augment it to do what I needed.

How Does Anansi Work

This section is kept brief. If you are interested in a deeper dive into how Anansi works, I recommend visiting the GitHub repo, reading the research paper, or reviewing this slideshow. The paper and slides may become outdated as the tool is updated. I believe they correspond to version 0.4.0.

Anansi is a dialogue management runtime built around the Ink narrative scripting language and a character social simulation. It uses Ink tags, naming conventions, and C# code to hijack Ink’s normal story flow to support parameterized storylets. The simulation is managed by Anansi-specific code and a relationship system tool I released on the Unity Asset Store.

Storylet systems often use preconditions to determine which storylets are eligible to show the player as the player navigates through story content. Anansi uses preconditions that bind values to variables. Each valid combination of variable values represents a valid instance of how a storylet could be parameterized. For example, let’s imagine we are writing a scene where the player meets a friend for lunch. We intentionally leave the friend variable ambiguous because we plan to reuse this scene with any NPC on friendly terms with the player. If the player has multiple friends, any of them could be eligible to appear in the scene when it is instantiated and shown to the player.

The ability to dynamically cast characters enables Anansi to empower writers to take advantage of emergent social states when writing more structured game content. Designers can write scenes that seek out particular social situations, present them to the player, use the player’s choices to trigger changes in the social relationships between characters, and repeat the process.

Description
Storytelling in games exists on a spectrum from linear to branching to procedural. The circles represent plot points, and the arrows show hand-authored connections from one plot point to the next. Linear storytelling moves the player from plot point to plot point without any say in the matter. Branching allows the player to move between various predefined plots. Procedural storytelling allows the player to chart their own course through various story fragments. The dotted arrows represent the plot points connected at runtime by player choice.

Building an Educational Game

Most of Anansi’s development occurred as part of a research effort to create an interactive educational narrative game about the responsible conduct of research. I was the programmer for the simulation and narrative tools. As part of my job, I worked with the writers to help them learn how to use Ink and Anansi’s storylet mechanics. Our team size ranged from 4 to 8 people. The game was intended to be a dynamic narrative experience that required the player to navigate social relationships between characters. Players’ choices could have immediate or second-order social consequences throughout the story.

Lessons Learned

1. Start small

When building a new game, especially one built on an experimental tool/workflow, it is important to start small with a prototype or vertical slice. While developing the educational game, the scope repeatedly exploded past what we could manage as a small team. Moreover, the increasing scope did not afford writers enough time to get comfortable using the more dynamic Anansi features. Writers tended to stick with writing branching dialogue because it was more familiar and faster for them to create.

2. Designers need no-code debug tools

Once the educational game grew above a handful of scenes, it became necessary to create tools to help writers debug stories. Without any ad hoc tools, writers were forced to replay the story from the beginning whenever they wanted to test the content. This process didn’t scale when working on scenes that appeared toward the end of the game. I provided writers with some basic tools that visualized the game state, but we never had a robust toolkit to let them start the story at a checkpoint, view/edit variables, and repeat.

3. Experimental tools should come with examples and design patterns

This lesson relates to writers avoiding Anansi’s storylet features in favor of Ink’s branching narrative features, which were more familiar to them. Had I had more time prior to developing the game, I would have put together better samples for writers to review and customize.