Gleam BEAM OTP Hex Big Bounce Tests Version License


“Aion turns. Chronos forgets. The seed remembers.”


viva_aion IS NOT A MAZE GENERATOR. It is a cyclic cosmology engine — deterministic labyrinths, retrocausal pathfinding toward an inevitable singularity, and a Big Bounce that transforms accumulated entropy into the DNA of the next universe.

Memories with high DRE score (Distinctiveness × Recency × Emotionality) survive the bounce. Everything else returns to the seed.


🎯 Overview

Aion (αἰών) is cyclic / eternal time in Greek philosophy, opposed to Chronos (linear time). VIVA experiences time cyclically:

Birth → Navigate labyrinth → Accumulate entropy
                                    │
                                    ▼
                          Reach Core (Leviathan)
                                    │
                                    ▼
                              Singularity
                                    │
                                    ▼
                  entropy transforms into seed
                                    │
                                    ▼
                            New Universe
PropertyValue
LanguagePure Gleam (type-safe functional)
RuntimeBEAM / OTP 26+
DeterminismSame seed = same universe, always
Tests53 passing
AlgorithmsRecursive Backtracker · BFS · DRE scoring · seed mutation
Public APIviva_aion + 10 internal modules

Inspired by:


⚡ Quick Start

gleam add viva_aion
import viva_aion

pub fn main() {
  // Genesis world
  let world = viva_aion.new()

  // ...or from a string seed
  let world = viva_aion.from_string("my_universe")

  let start = viva_aion.start_position(world)
  let core  = viva_aion.core_position(world)

  // Retrocausal pull: which way is the Core?
  case viva_aion.suggest_move(world, start) {
    Ok(direction) -> direction
    Error(_) -> // dead end
      direction
  }
}
📋 Prerequisites
ToolVersionRequired for
Gleam>= 1.4Build / runtime
Erlang/OTP>= 26BEAM target

Zero NIFs. Zero C dependencies. Pure functional.


🏗️ Architecture

   ┌──────────────────────────────────────────────────────────┐
   │                Gleam application code                    │
   │      viva_aion.{new, bounce, suggest_move, ...}          │
   └────────┬─────────────────────────────────────────────────┘
            │
   ┌────────▼─────────────────────────────────────────────────┐
   │                   viva_aion modules                      │
   │                                                          │
   │   ┌────────┐  ┌──────────┐  ┌─────────┐  ┌────────────┐  │
   │   │  seed  │  │   rng    │  │  tile   │  │  position  │  │
   │   │ DNA    │  │ deterministic ops      │  │ 2D coords  │  │
   │   │ mutate │  │          │  │ Wall    │  │ + move     │  │
   │   └────┬───┘  └────┬─────┘  │ Path    │  └─────┬──────┘  │
   │        │           │        │ Core(@) │        │         │
   │   ┌────▼───────────▼──┐     └─────────┘   ┌────▼─────┐   │
   │   │     generator     │                   │   grid   │   │
   │   │   Recursive       │                   │ 2D spatial   │
   │   │   Backtracker     │                   │ structure│   │
   │   └─────────┬─────────┘                   └────┬─────┘   │
   │             │                                  │         │
   │   ┌─────────▼──────────┐                ┌──────▼─────┐   │
   │   │   pathfinding      │                │   memory   │   │
   │   │ BFS · light cone   │                │ records    │   │
   │   │ retrocausal pull   │                │ that       │   │
   │   └────────────────────┘                │ transcend  │   │
   │                                         └────┬───────┘   │
   │                                              │           │
   │                                       ┌──────▼─────┐     │
   │                                       │   dream    │     │
   │                                       │ DRE scoring│     │
   │                                       └────────────┘     │
   └──────────────────────────────────────────────────────────┘
📋 Core modules
ModulePurpose
viva_aionTop-level API (world, navigation, bounce, memory)
viva_aion/seedUniverse DNA + hash-based mutation across bounces
viva_aion/rngDeterministic PRNG seeded by the universe seed
viva_aion/tileTile types: Void, Wall, Path, Core
viva_aion/position2D coordinates + directional movement
viva_aion/grid2D spatial structure for the labyrinth
viva_aion/generatorRecursive Backtracker maze generation
viva_aion/pathfindingBFS, light cone expansion, retrocausal pull
viva_aion/memoryMemory records with access counts + importance
viva_aion/dreamDRE scoring (Distinctiveness × Recency × Emotionality)
viva_aion/logStructured logging helpers

🧬 Theoretical Background

Determinism

Same seed = same universe. Always.

let world1 = viva_aion.from_string("seed")
let world2 = viva_aion.from_string("seed")
// world1 == world2 — identical labyrinths

Seed Mutation (Big Bounce)

Accumulated entropy of one life becomes the DNA of the next:

let next_seed = seed.mutate(current_seed, entropy, extra_data)

Hash-based transformation:

Retrocausality

The Core (goal) “pulls” the present decision — implementing Active Inference by minimizing expected free energy toward the attractor.

let direction = pathfinding.retrocausal_pull(grid, current, core)

DRE Scoring — Walker & Stickgold (2006)

Memory consolidation during sleep selects which experiences survive:

DRE = D × R × E (weighted)

D = Distinctiveness — how unique?
R = Recency        — 0.5^(age / half_life)
E = Emotionality   — intensity at creation

Plus bonuses for access count, manual importance, and prior transcendence. High-DRE memories survive the Big Bounce. Low-DRE memories dissolve back into entropy.

Tile Vocabulary

TileSymbolMeaning
Void Beyond existence
Wall#Structure
Path.Passable
Core@Singularity (Leviathan)

🎨 Design Principles

PrincipleDescription
Deterministic cosmologySame seed = same universe; reproducible across machines
Retrocausal navigationFuture attractor influences present move ranking
Memory transcendenceOnly high-DRE memories survive the Big Bounce
No floating clockTime progresses via discrete memory_tick calls
Visual debug first-classvisualize / visualize_at ship in the public API

📚 Public API Highlights

Navigation

let moves = viva_aion.rank_moves(world, current_pos)
// => [(Up, 15), (Left, 17), (Down, 18), (Right, 20)]

let new_pos = viva_aion.try_move(world, current_pos, direction)

let cone = viva_aion.light_cone(world, pos, 5)
// All positions reachable within 5 steps

Memory + Dream (DRE)

let bank = viva_aion.new_memory_bank(1)
let #(bank, mem1) = viva_aion.remember(bank, 42, 0.8)
let #(bank, mem2) = viva_aion.remember_important(bank, 99, 0.9, 0.7)

let bank = viva_aion.memory_tick(bank)
let #(bank, _) = viva_aion.recall(bank, mem1.id)

let score = viva_aion.score_memory_default(mem1, bank)
// score.total · score.distinctiveness · score.recency · score.emotionality

Big Bounce — world only

let new_world = viva_aion.bounce(world, entropy: 42.0, extra: "pos:15,16")

Big Bounce — with memory transcendence

let #(new_world, new_bank) =
  viva_aion.bounce_with_memories(
    world, bank, entropy: 42.0, extra: "extra",
    max_survivors: 10,
    min_threshold: 0.3,
  )

let past    = viva_aion.past_life_memories(new_bank)
let current = viva_aion.current_life_memories(new_bank)

Visualization

let ascii = viva_aion.visualize(world)
//
// ################################
// #.......#.....#...#............#
// #.#####.#.###.#.#.#.##########.#
// #.#...#.#...#...#.#............#
// ...
// ###############@################

let ascii = viva_aion.visualize_at(world, current_pos)
// X marks the spot

🗺️ Roadmap

PhaseStatus
Deterministic seed + RNG
Recursive Backtracker maze generation
BFS pathfinding + light cone
Retrocausal pull toward Core
Memory bank + recall
DRE scoring (Walker & Stickgold)
Big Bounce — world-only seed mutation
Big Bounce — memory transcendence
ASCII visualization
Multi-layer universes (3D labyrinths)
Probabilistic light cone (action policies)
Persistent universe save/load
Memory clustering for narrative dreams

🤝 Contributing

git checkout -b feature/your-feature
gleam test                  # 53 tests
gleam format --check src test
gleam build

See CHANGELOG for release history.


📖 References


🌌 VIVA Ecosystem

PackagePurpose
viva_mathMathematical foundations
viva_emotionPAD emotional dynamics
viva_tensorFP8 LLM inference on the BEAM
viva_telemetryObservability suite
viva_aionCyclic time + cosmology (this package)
viva_glyphSymbolic language

Star if you believe time should loop ⭐

GitHub stars

Created by Gabriel Maia · MIT License

Search Document