# Multilinear Story System
[](https://crates.io/crates/multilinear)
[](https://docs.rs/multilinear)
A Rust library for building interactive stories with constrained parallel aspects.
## Overview
Model narrative systems using:
- **Aspects**: Independent state machines representing story aspects
- **Events**: Coordinated transitions across multiple aspects
- **Safe Composition**: Guaranteed valid states through transition constraints
Inspired by petri nets but designed for narrative applications.
## Features
- 🚦 Aspects with discrete value transitions
- ⚡ Event-driven story progression
- 🔄 Backward simulation capabilities
- 🛡️ Prevention of creating invalid event transitions
- 📈 Efficient tracking of current state and available events
## Quick Start
```rust
use event_simulation::Simulation;
use multilinear::{Change, MultilinearInfo, MultilinearSimulation};
let mut story = MultilinearInfo::new();
// Create aspects
let place = story.add_aspect();
let clothes = story.add_aspect();
// Define event: Move from bedroom to living room
let event_move = story
.add_event()
.with_change(&[Change::transition(place, 0, 1)])
.unwrap()
.event();
// Define event: Change clothes in bedroom
let event_clothes = story
.add_event()
.with_change(&[
Change::condition(place, 0),
Change::transition(clothes, 1, 0),
])
.unwrap()
.event();
let mut simulation = MultilinearSimulation::new(story);
simulation.try_call(event_clothes);
simulation.try_call(event_move);
simulation.try_revert(event_move);
```
## Core Concepts
- Aspect: Independent state machine representing a variable of the story state (like the player location or the relationship to somebody)
- Change: A requirement of an aspect, also capable of changing that aspect (like changing the player location from livingroom to kitchen)
- Event: Transition rule combining multiple aspect conditions