- Published on
Time Traveling and Branching Simulations
- Authors
- Name
- Francois Laberge
- @seflless
Introduction
With Convey, I want running simulations of your ideas to be as easy as playing videos. Often like in a sports game, you need to rewatch and/or slow-mo a situation in order to understand what happened. Bonus points if you can see from different viewpoints too.
Why Branching?
When designing things, it's always hard to think of all the possibles states and scenarios you need to handle. Often this is dealt with by creators making a complex flowchart of all the possible states and events that can occur. This is very error prone, costly to develop, and frankly not much fun.
Here's an example of a flowchart modeling a simple dog walk simulation.
Statecharts: Flowcharts within Flowcharts
I'm really understating the issue. In most software there are concurrent states and many of them, each concurrently reacting to events. Flowcharts are not designed to model anything but systems having one state at a time. People can work around this somewhat by enumerating all state combinations and combinations names. Ex. SignedIn-NetworkAvailable, SignedOut-NetworkAvailable, SignedIn-NetworkUnavailable, etc.
Enter statecharts, a flowcharts like system, growingly in popularity with developers. Statecharts allow nesting statemachines (the academic name for flowcharts), running them concurrently, and allowing them to send events to each other. Here's an example of a richer dog walk simulation flow. Note how the "on a walk" state from the simple flowchart above is now a flowchart in of itself.
Unfortunately tools for designing them are still rough around the edges and geared towards developers. Stately is a new company building a statechart editor though that is very user friendly, I use it heavily in Convey's code. It's mostly developers starting to use it, but it will likely start to get used by designers, especially those on teams with apps built on xstate, a statechart runtime also built by the founders of Stately.
The dog walk diagrams are from xstate's Introduction to state machines & statecharts.
Uncovering State-space via Simulation Play
Classes of software that are highly emergent don't really match flowcharts/statecharts at the macro level, though can be at a module level. For instance in games, you can have things like physics simulation, many types of entities, and many ways they can each effect each other. The size of the state space explodes because of this and enumerating them is impossible. Suffice to say, I think the following technique should be available in the Convey toolbox, on top of supporting flowcharts/statecharts.
The gist of the technique I'm exploring is:
- Designers/developers should just create a rough working simulation of their concept
- Convey will support easily starting/pausing a simulation
- Playing to any point and saving where you are at any time
- From any save point you can try different scenarios
- Each branched timeline can be replayed start to finish
- Each branched timeline can be named and shared
- This way all told
- Everyone can contribute to thinking about and discovering scenarios
- Running scenarios and see where things break or is optimal is kind of the point of simulations
In a mathematical sense, game/game-like simulations are better thought of as continuously changing than discrete. I don't want Convey to be unfriendly to more discrete style experiences, I'm just focusing this writeup on why I'm making branching a core feature that will hopefully make Convey a joy to use for making emergent type experiences.
I'd like to focus the UX of Convey on simpler simulations use cases, like the early phase of a game's design, or an isolated game mechanic of a game further along. Even when keeping it simple, enumerating the possible scenarios becomes prohibitively expensive, so the points I'm making should still stand.
Runway
Support for save points and branching is very similar to how classic AI, now modern reinforcement learning, and formal program verification work. Though here humans act as the computers trying out scenarios. There are probably some tricks from those fields to bring into Convey eventually, but so far they aren't particularly user friendly by a typical software creator.
My thinking was heavily influenced by a tool called Runway. It was built by the creator of the Raft concensus algorithm. Runway allows algorithm creators to specify objects and actions/events that change them. The system enables a computer to automatically explore scenarios and detect certain conditions (like failure modes). This is used to quickly find issues with an algorithm. There is a hosted webapp where you can also run algorithms and manually trigger events, supporting branching timelines.
Recap
- Building game-like simulations enables groups to playfully discover the bounds of an idea
- Replay really helps for understanding and Branching really helps for thinking/discovery
I'll write more about branching in future posts and go deeper into how simulation, time-traveling, and multiplayer fit into the Convey vision.
Follow @seflless and @convey_it on Twitter, to see Convey's progress and more experiments.