Perchance Tech Report

Perchance Engine Architecture

This technical report documents the internal mechanics of the Perchance.org text generation engine. Unlike simple randomizers, Perchance operates on a hierarchical recursive grammar system combined with a JavaScript-based state machine. This application allows you to explore the probability curves, state persistence patterns (consumable lists), and the integration layer that bridges simple text lists with complex web APIs.

Recursive Grammar

Deep nesting support with syntax like [list.subItem] allowing for complex, branching narrative structures.

Event-Driven

The engine is wrapped in a reactive membrane, allowing DOM updates to trigger re-evaluation of specific list nodes.

Plugin System

Modular extension capabilities allowing integration with LLMs, text-to-speech, and external APIs via simple import syntax.

Execution Pipeline

📄
Source Parsing
YAML-like syntax to JSON tree
Evaluation
Recursive resolution & Weight calculation
Loop
💻
Render / State
DOM Injection & Variable Update