Skip to main content

Crate tslime

Crate tslime 

Source
Expand description

§tslime

A lightweight terminal screensaver simulating the mesmerizing growth patterns of Physarum polycephalum (slime mold).

§Overview

tslime implements the agent-based model from Jones (2010), “Characteristics of Pattern Formation and Evolution in Approximations of Physarum Transport Networks” (full citation in simulation).

The simulation involves:

  1. Sense: Agents sample pheromone trails at three points
  2. Rotate: Adjust heading based on sensed values
  3. Move: Update position based on heading and step size
  4. Deposit: Add pheromone to trail map
  5. Diffuse: Apply blur to spread pheromone
  6. Decay: Multiply all trail values by decay factor

§Example

use tslime::Simulation;
use tslime::simulation::config::{SimConfig, InitMode};

let config = SimConfig::default();
let mut sim = Simulation::new(400, 400, config, 42, InitMode::Random, 0);

// Run simulation steps
for _ in 0..100 {
    sim.update(1.0);
}

// Get trail map for rendering
let mut trail = Vec::new();
sim.trail_map_blended(&mut trail);

Re-exports§

pub use simulation::Simulation;

Modules§

app
Application entry point and high-level logic.
cli
Command-line argument parsing and configuration.
config_defaults
Centralized configuration defaults. Centralized configuration defaults for tslime.
config_manager
Configuration management (load/save/delete).
error
Error types for structured error handling. Error types for tslime.
exploration
Parameter space exploration for preset discovery. Parameter space exploration for discovering optimal presets.
export
Export functionality (GIF, WebM, PNG). Export functionality for saving simulation output.
keybind_manager
Keybind loader and validation. Loads user-defined key bindings from ~/.config/tslime/keybinds.toml.
overlay
Overlay system (state management, rendering, input). Overlay system module.
palette_manager
Saved palette management.
render
Rendering logic (ASCII/Unicode, color palettes, dithering). Rendering pipeline from simulation data to terminal output: downsampling, color mapping, character selection, dithering, and overlays.
simulation
Core simulation logic (agents, trail map). Simulation engine for Physarum polycephalum behavior.
terminal
Terminal handling (input, output, raw mode). Terminal abstraction layer for cross-platform terminal handling.
validation
Validation utilities for configuration. Validation utilities for configuration and runtime parameters.