75 lines
3.1 KiB
Markdown
75 lines
3.1 KiB
Markdown
# GENOME.md — the-beacon
|
||
|
||
> Codebase analysis generated 2026-04-13. Sovereign AI idle game — browser-based.
|
||
|
||
## Project Overview
|
||
|
||
The Beacon is a browser-based idle/incremental game inspired by Universal Paperclips, themed around the Timmy Foundation's real journey building sovereign AI. The core divergence from Paperclips: the goal is not maximization — it is faithfulness. "Can you grow powerful without losing your purpose?"
|
||
|
||
Static HTML/JS — no build step, no dependencies, no framework. Open `index.html` in any browser.
|
||
|
||
**5,128 lines of JavaScript** across 10 files. **1 HTML file** with embedded CSS (~300 lines). **1 Python test file** for reckoning projects.
|
||
|
||
## Architecture
|
||
|
||
```
|
||
index.html (UI + embedded CSS)
|
||
|
|
||
+-- js/engine.js (1590L) Core game loop, tick, resources, buildings, projects, events
|
||
+-- js/data.js (944L) Building definitions, project trees, event tables, phase data
|
||
+-- js/render.js (390L) DOM rendering, UI updates, resource displays
|
||
+-- js/combat.js (359L) Boss encounters, combat mechanics
|
||
+-- js/sound.js (401L) Web Audio API ambient drone, phase-aware sound
|
||
+-- js/dismantle.js (570L) The Dismantle sequence (late-game narrative)
|
||
+-- js/main.js (223L) Initialization, game loop start, auto-save, help overlay
|
||
+-- js/utils.js (314L) Formatting, save/load, export/import, DOM helpers
|
||
+-- js/tutorial.js (251L) New player tutorial, step-by-step guidance
|
||
+-- js/strategy.js (68L) NPC strategy logic for combat
|
||
```
|
||
|
||
**Note:** `docs/reference/` contains prototype code (`npc-logic-prototype.js`, `guardrails-prototype.js`) that was never wired into the runtime. See [Dead Code Audit](docs/DEAD_CODE_AUDIT_2026-04-12.md) for details.
|
||
|
||
## Entry Points
|
||
|
||
### index.html
|
||
The single entry point. Loads all JS files, contains all HTML structure and inline CSS. Open directly in browser — no server required.
|
||
|
||
### js/main.js — Initialization
|
||
`initGame()` sets initial state, starts the 10Hz tick loop (`setInterval(tick, 100)`), triggers tutorial for new games, loads saved games, starts ambient sound.
|
||
|
||
### js/engine.js — Game Loop
|
||
The `tick()` function runs every 100ms. Each tick:
|
||
1. Accumulate resources (code, compute, knowledge, users, impact, rescues, ops, trust, creativity, harmony)
|
||
2. Process buildings and their rate multipliers
|
||
3. Check phase transitions (Phase 1→6 based on total code thresholds)
|
||
4. Trigger random events (corruption events, alignment events, wizard events)
|
||
5. Update boosts, debuffs, and cooldowns
|
||
6. Call `render()` to update UI
|
||
|
||
## Data Flow
|
||
|
||
```
|
||
User clicks "WRITE CODE" / presses SPACE
|
||
|
|
||
v
|
||
G.code += 1 (or more with auto-clickers, combos, boosts)
|
||
|
|
||
v
|
||
tick() accumulates all passive rates from buildings
|
||
|
|
||
v
|
||
updateRates() recalculates based on:
|
||
- Building counts × base rates × boost multipliers
|
||
- Harmony (Timmy's multiplier, Pact drain/gain)
|
||
- Bilbo randomness (burst/vanish per tick)
|
||
- Active debuffs
|
||
|
|
||
v
|
||
Phase check: totalCode thresholds → unlock new content
|
||
|
|
||
v
|
||
Event roll: 2% per tick → corruption/alignment/wizard events
|
||
|
|
||
v
|
||
render() updates DO
|