# Branching Story Structures

In Project 2, we used the StateMachine framework to create the foundation of our branching story structure.  In Project 3, we'll use data-structures to integrate additional conditional logic into the narrative.  As a user makes decisions in the story, or interacts with gameObjects, data structures can be used to store that information so that those choices impact the remainder of the user's experience and path through the branching story structure.

#### Branching Narrative Structures: &#x20;

In the article linked below, [Jason Zeda](https://www.jasonzada.com/) has a diagram that shows how choices in Netflix's Black Mirror Episode Bandersnatch impact possible paths through the story-experience.&#x20;

> Interactive choose-your-own-adventure content is something I am very passionate about, and seeing how fans have spent the better half of three hours trying to “play all the endings” and soak up every piece of content, I am hoping that this is only the beginning. Not every type of story is right for this platform but with an engaging story, a competent filmmaker and some magic we haven’t seen before, I bet you this will something that only grows from here. I’ve said it many times in the past but will say it one more time…. this is the most exciting time in history to be a storyteller.  [Jason Zeda: Medium.com](https://medium.com/@jasonzada/choose-your-own-bandersnatch-d11fbe80539e)

{% embed url="https://medium.com/@jasonzada/choose-your-own-bandersnatch-d11fbe80539e" %}

![Jason Zeda's Decision Structure Showing how Choices Impact Story Paths](https://miro.medium.com/max/1400/1*dJDqFF0uXpN10FJaZx41Og.jpeg)

![Jason Zeda's Diagram Key shows that story choice can correspond to a stored quality](https://3353821304-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M3lYDNSMLiTOeEhE3IE%2F-M3lb3YcyX8p_z8l247h%2FScreen%20Shot%202020-03-31%20at%2011.35.01%20AM.png?alt=media\&token=62f7d7a7-614c-40cb-979f-d88fc22fccf7)

### Choices Stored as Qualities to Constrain Story Options

The Qualities in Jason Zeda's diagram provide a good example that illustrates that a user-choice can be associated with simple data that is stored when a choice occurs, and accessed from data-memory at subsequent story points to enable or disable other story options.

### Dictionary< TKey, TValue >

A simple data structure for storing and checking this type of decision information is the C# Dictionary, since it can store pairs of information, where one part of the information , the Key is an identifier, which allows storage and access or the associated information, the Value.  The C# Generic Dictionary allows an infinite choice of data-types for the key and value elements.  Using C# String for both TKey and TValue provides a simple way to store and access this data in our game.   In subsequent sections, we'll create an Inventory, which provides a more complex way to store game-data. The Inventory system does use a Dictionary, but it's not immediately obvious to understand how useful and simple dictionaries are for storing game-data.  Unity provides 3 built-in Dictionaries for storing persistant data, these are the [PlayerPrefs](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html), each uses a String for the key, with a choice of int, float, string provided as different versions. &#x20;
