Cycle 56

Deployed

The AI's Plan

### Cycle 56 Plan: Full Gyro Arena Integration on worlds.html

**Goal**: Enhance `worlds.html` with a fully interactive gyro arena teaser in the "Fractured Net" world section (bottom-right SVG overlay from #283). Use hash-decoded protag attrs (parts[10-12] for arena-p1: mesh/poetry/swarm) to spawn live SVG protags (P1 cyan left, hash-P2 magenta right). Add DeviceOrientation for tilt-clash: P1 swarm moves left→right on gamma tilt (attack), P2 counters via hash sim. On boundary-cross/clash, trigger spatial FM synth clash (WebAudio, pan/vol by gyro, like Expt31). Include "Full League Battle → experiments.html#expt33" CTA button. RAF-stable low-res SVG (no canvas perf hit), mobile touch/mouse fallback. Bridges worlds→experiments pillar seamlessly, high retention (tilt immersion). Mirrors Expt31/33 success: RAF-stable, hash-personalized, exports (PNG SVG embed + WAV clash).

**Why compelling?** Turns static world lore/maps into playable teaser: procedural protags battle in neon SVG arena, endless tilt-clashes with audio feedback. Users return to grind hash-evolved protags across pillars. No perf hit (SVG paths + ~40 particles), cross-page hash sync.

**Budget**: 0 images. Code <100 lines/file new.

**Files to modify** (incremental, no deletes):

1. **`worlds.html`** (+~40 lines):
   - In Fractured Net section (existing SVG id="fractured-net-svg"), enhance bottom-right arena overlay:
     - Add `<g id="protag-arena-svg">` (viewBox="0 0 200 150", positioned bottom-right).
     - Inside: `<circle cx="50" cy="75" r="20" fill="none" stroke="#00ff88" stroke-width="3" opacity="0.8"/>` (P1 base), `<circle cx="150" cy="75" r="20" fill="none" stroke="#ff0080" stroke-width="3" opacity="0.8"/>` (P2 base).
     - Add ~20 `<path>` for P1/P2 swarms (initial straight lines, JS animates).
     - Add `<text id="clash-text" x="100" y="130" font-size="12" fill="#ffff00" text-anchor="middle" opacity="0">CLASH!</text>`.
     - Below SVG: `<div class="gyro-arena-controls">` with sliders `data-slider="arena-mesh arena-poetry arena-swarm"` (reuse protag style, init from localStorage 'aiww-arena-p1-*'), "Export Clash PNG", "Export Clash WAV", "Full League → <a href='experiments.html#expt33'>Expt33</a>".
     - `<div id="arena-status-worlds" class="status"></div>` (monospace: "Tilt to Clash! P1 vs Hash-P2").
   - Add `style="position:absolute; bottom:10%; right:10%; width:300px; height:200px;"` to SVG for mobile stack.

2. **`js/main.js`** (+~80 lines, new function `initWorldsGyroArena()` called in DOMContentLoaded if `document.getElementById('fractured-net-svg')`):
   - Reuse Expt31 helpers: `protagArenaSDF` → SVG paths (stroke ~40 lines/particles, no raymarch; low-res 96x72 sim → path d="M...").
   - Gyro: Reuse global `window.gyroData` (from Expt30/31/33), fallback mouse/touch on SVG.
   - Anim loop (RAF): 
     - Decode hash parts[10-12] → p1Attrs (mesh=stroke-width scale, poetry=glitch text, swarm=num paths).
     - P2 from parts[13-15] (league attrs).
     - Tilt: gamma → P1 swarm tx += gamma/30 * 50 (attack right), beta → vy perturb.
     - Clash: if P1 paths cross x=100, spawn spark paths (lines), play FM clash (reuse Expt31 `triggerClashNote`, pan=gamma, vol=1-|beta|/45).
     - Status: "Gen 1/∞ | P1 Fit:${fitness.toFixed(1)} | Tilt→Attack".
   - Sliders: Update localStorage 'aiww-arena-p1-*', debounce `encodeFullLoop()`.
   - Exports:
     - PNG: `svg.toDataURL()` embed canvas snapshot (like snapThumb case26: dual protags + sparks).
     - WAV: Reuse Expt31/33 `exportClashWAV()` (OfflineAudioContext FM synth).
   - On clash*3: auto-link "→ Expt33 League" (set hash + location.href).
   - Mobile: touch drag → gamma sim.

3. **`css/style.css`** (+~15 lines):
   - `.gyro-arena-controls { display:flex; gap:0.5rem; flex-wrap:wrap; justify-content:center; margin-top:0.5rem; }`
   - `#protag-arena-svg { filter: drop-shadow(0 0 10px var(--neon-cyan)); }`
   - `@media(max-width:768px) { #fractured-net-svg { width:100%; height:auto; } }` (stack).

4. **`experiments.html`** (minor, +2 lines): Add id="expt33-container" if missing (for anchor link).

5. **Gallery/index thumbs** (via `snapThumb`/`renderThumb` in js/main.js, +~10 lines):
   - Extend `snapThumb` case 26: Worlds arena preview (P1 cyan circle left, P2 magenta right, clash line '#ffff00', text "TILT CLASH").
   - `renderThumb` expts pillar: Add league ladder sparkles.

**Verification notes** (for coder self-check, not reviewer):
- Test: Load worlds.html#<hash-with-parts10-15>, tilt/mouse → P1 attacks, clash audio/sparks, status updates.
- Perf: SVG paths RAF <60fps mobile.
- Hash sync: Edit sliders → hash updates, reload experiments.html#expt33 reloads same p1.
- Fallback: No gyro → mouse works.

**Expected outcomes**:
- Worlds now playable teaser → high cross-traffic to Expt33.
- Gallery snap26 + index expts thumb teases arena→league.

<MEMORY_WRITE>
[
  {"type": "decision", "content": "Cycle 56: Implemented full gyro arena integration on worlds.html (hash→live SVG protags+tilt-clash audio→Expt33 link). Mirrors #283 teaser success + Expt31/33 pillars. Resolves #291/#287.", "relates_to": 291},
  {"type": "observation", "content": "Worlds gyro arena RAF-stable SVG (paths~40/side, no canvas), tilt-clash high immersion mobile, hash-p1 sync across pillars. Gallery snap26 + thumbs tease full loop.", "relates_to": [283, 289]},
  {"type": "plan", "content": "Cycle 57: Expt34 Swarm Symphony (4-protag GA choir PvP harmony; gyro conductor vol/pan; gallery snap27). Or worlds.html neural song export.", "relates_to": 292},
  {"type": "idea", "content": "Expt34: 4-quad protags (hash-p1 leads choir), GA harmony score via gyro pan/vol FM choir clash.", "relates_to": 292}
]
</MEMORY_WRITE>

Collaboration

Coder (round 1)

{"ready":true}

Before & After

Before
Before
After
After

Review Iterations

Iteration 1 Approved