Skip to content

Repository files navigation

Vireo — Interactive Ecosystem Sandbox

An interactive ecosystem simulation built on a custom GPU engine, featuring diffusion fields, emergent behavior, and massive-scale particle systems. Built with Rust and WGPU for high-performance simulation.

Inspired by Mote by Peter Whiddennot affiliated.

About

Vireo is a GPU-native ecosystem sandbox that explores emergent behavior through simple rules and massive scale. The simulation features a 2D diffusion field, independent agent particles, and a behavior kernel that creates complex interactions from simple components.

This project re-implements concepts from scratch and is not affiliated with Mote or its author. We're grateful for the inspiration and the community enthusiasm around large-scale emergent simulations.

What Changed in 0.1.x

  • Boundary behavior: Changed from wrapping to bouncing edges for more natural movement
  • Visual effects: Reduced intensity of feed/glow/stress effects for cleaner appearance
  • Seeding logic: Less clumpy distribution with broader, more natural food sources
  • State flags: Added visual indicators for reproduction, feeding, attacking, and herding states
  • Architecture: Replaced ring-spring physics with independent agent behaviors for improved stability and clarity

Features

  • GPU diffusion field (RGBA16F texture) with ping-pong rendering
  • Massive particle systems (20k by default, scalable to 50k+ on stronger GPUs)
  • Agent-based behaviors with independent particle decision-making
  • Emergent behaviors through simple rule sets:
    • Plants: stationary, energy-based growth in food-rich areas
    • Herbivores: follow food gradients, herd together, avoid predators
    • Predators: hunt herbivores, maintain territorial boundaries
  • Real-time rendering with instanced quads (no CPU copies)
  • Emissions system (toggle with E key) - particles leave trails that diffuse through the field
  • Clean architecture with separate compute and render pipelines
  • WebGPU compatible with automatic texture alignment for cross-platform support

Build & Run

# Requires Rust + cargo and a GPU that supports WebGPU (Vulkan/Metal/DX12)
cargo run --release

# For development/debugging (slower but more informative)
cargo run

Run the Demo

For headless experiments and long-running simulations:

# Run the closed-loop cycles demo (v0.3 milestone)
cargo run --release --package vireo-headless -- --config lab/configs/best-demo.yaml --out results

# Test individual components with debug scenarios
cargo run --release --package vireo-headless -- --scenario reaction-only --out results
cargo run --release --package vireo-headless -- --scenario diffusion-only --out results
cargo run --release --package vireo-headless -- --scenario uptake-only --out results
cargo run --release --package vireo-headless -- --scenario damping-only --out results

The demo will run 2000 steps on a 128×128 grid with 2000 herbivores, producing:

  • metrics.csv with cycle scores and foraging efficiency
  • occupancy_*.png snapshots at steps 0, 200, 1000, 2000
  • Field evolution visualizations

Demo Controls

  • Space — pause/resume simulation
  • R — re-seed the environment
  • C — reset camera to center view
  • E — toggle emissions (particle trails)
  • Esc — quit

Camera Controls

  • Mouse Wheel — zoom in/out
  • Left Click + Drag — pan around the world
  • C key — reset camera to center view

Environment Variables

# Particle count (default: 20,000)
VIREO_PARTICLES=50000 cargo run --release

# World dimensions (default: 1024x576)
VIREO_GRID_W=1024 VIREO_GRID_H=576 cargo run --release

Project Structure

src/main.rs               # WGPU initialization, pipelines, main loop
shaders/diffuse.wgsl      # 2D field diffusion (laplacian + decay)
shaders/particles.wgsl    # Particle physics + behavior kernel
shaders/emissions.wgsl    # Particle-to-field emissions system
shaders/render.wgsl       # Instanced quad renderer

Technical Details

  • Compute passes: Diffusion, particles, and optional emissions per frame
  • Memory layout: Optimized for GPU with minimal CPU-GPU transfers
  • Field format: RGBA16F texture with filterable sampling for smooth gradients
  • Texture alignment: Automatic 256-byte row padding for WebGPU compatibility
  • Scalability: Designed to handle 50k+ particles on consumer GPUs
  • Extensibility: Clean separation of concerns for easy modification

Future Directions

  • Advanced physics: Sparse neighbor systems for more realistic interactions
  • Genetic algorithms: Genome-based behavior evolution
  • ML integration: Python bindings for reinforcement learning
  • Multi-agent systems: Complex interaction networks
  • Enhanced emissions: More sophisticated particle-field interactions

Inspiration & Attribution

This project draws conceptual inspiration from Peter Whidden's talk on Mote. All code and assets in this repository are original unless otherwise noted. "Mote" is referenced for attribution only; this project is not endorsed by or associated with its author.

References:

License

MIT License - see LICENSE file for details.


Vireo: A world of interacting life, inspired by nature's complexity.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages