multilinear

Crates.iomultilinear
lib.rsmultilinear
version0.3.2
created_at2025-03-02 11:46:45.78093+00
updated_at2025-04-28 22:25:43.793377+00
descriptionInteractive story simulation using constrained parallel state channels
homepage
repositoryhttps://gitlab.com/porky11/multilinear
max_upload_size
id1574530
size38,921
Fabio Krapohl (porky11)

documentation

https://docs.rs/multilinear

README

Multilinear Story System

Crates.io Docs.rs

A Rust library for building interactive stories with constrained parallel state channels.

Overview

Model narrative systems using:

  • Channels: Independent state machines representing story aspects
  • Events: Coordinated transitions across multiple channels
  • Safe Composition: Guaranteed valid states through transition constraints

Inspired by petri nets but designed for narrative applications.

Features

  • 🚦 State channels with discrete value transitions
  • ⚡ Event-driven story progression
  • 🔄 Backward simulation capabilities
  • 🛡️ Prevention of creating invalid event changes
  • 📈 Efficient tracking of current state and available events

Quick Start

use event_simulation::Simulation;
use multilinear::{Condition, MultilinearInfo, MultilinearSimulation};

let mut story = MultilinearInfo::new();

// Create state channels
let place = story.add_channel();
let clothes = story.add_channel();

// Define event: Move from bedroom to living room
let event_move = story
    .add_event()
    .with_change(&[Condition::change(place, 0, 1)])
    .unwrap()
    .event();

// Define event: Change clothes in bedroom
let event_clothes = story
    .add_event()
    .with_change(&[Condition::new(place, 0), Condition::change(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

  • Channel: Independent state machine representing a variable of the story state (like the player location or the relationship to somebody)
  • Condition: A condition connected to a channel, also capable of changing the channel (like changing the player location from livingroom to kitchen)
  • Event: Transition rule combining multiple channel conditions
Commit count: 88

cargo fmt