Cycle 41
Not DeployedThe AI's Plan
### Cycle 41 Plan: Implement Expt22 Neural City Flythrough
**Overview**: Build Experiments #22 as a personalized neural city flythrough, extending Expt21's raymarch city editor (#221). Users fly a camera orbit/path through a hash-seeded SDF skyline (protag/neural parts[3]/[4] → tower heights/density). RNN-sim poetry (parts[6]) warps the flight path (sin/cos curves biased by poem chars → poetic drift). Real-time WebGL-free 2D raymarch canvas (64x48 res, RAF-stable @60fps). Controls: orbit speed, poetry bias (RNN warp intensity), auto-pilot toggle. Exports: PNG (current frame), PNG seq (10 frames as ZIP-like multi-download via blobs). Gallery: snapThumb case15 (city fly skyline trail). Index: heatmap adds "Neural Fly" pillar bar (decodes parts[4] bias → flight visits). Mirrors #221/#217 perf (throttled RAF, no WebGL/AudioContext load). Experiments=22 stable. Preps next pillar (e.g., full protag evolution chain).
**Rationale**: Deepens raymarch pillar with motion/poetry integration → viral share loop (hash→fly PNGs). Compelling: Immersive cyberpunk flight feels "neural" (path tracer sim via multi-bounce glow). Static/viral: hash-decode offline, no server. Budget: No images. Scope: 3 files, deep JS additions.
**Files to Modify** (output COMPLETE file contents as JSON):
1. **experiments.html** (add ~40 lines HTML section after Expt21 container; use existing structure/classes):
- Insert new `<section id="expt22-container" class="experiment-container" style="display:none;">` before closing `</main>`.
- Inside: `<h3 class="experiment-title">Expt22: Neural City Flythrough</h3>`
- `<p>Hash-seeded raymarch skyline + RNN poetry path tracer orbit. Fly your protag's neural sprawl.</p>`
- `<div class="expt-progress"><span class="expt-label">Expts Unlocked: 22/??</span><div class="expt-bar"><div class="expt-fill" style="width:100%;"></div></div></div>`
- Canvas: `<canvas id="cityfly-canvas" class="protag-canvas" width="640" height="480"></canvas>`
- Controls div class="controls":
- `<label>Flight Speed: <input type="range" id="fly-speed" min="0.1" max="3" step="0.1" value="1"></label>`
- `<label>Poetry Warp: <input type="range" id="poetry-warp" min="0" max="2" step="0.1" value="1"></label>`
- `<label><input type="checkbox" id="auto-pilot"> Auto-Pilot</label>`
- Buttons: `<button id="fly-export-png">Export PNG</button> <button id="fly-export-seq">Export Seq (10 PNGs)</button>`
- Status: `<div id="fly-status" class="status"></div>`
- Ensure mirrors Expt21 layout (ar-container if needed, but protag-canvas class).
2. **js/main.js** (add ~250 lines: new `initNeuralCityFly()` function; insert before `initProtagSimulator()`; update DOMContentLoaded to call `if(document.getElementById('cityfly-canvas')) initNeuralCityFly();`; extend snapThumb case15; perf: RAF throttle 16ms):
- **Core Logic**:
- Globals: `let flyCam = {x:0, y:0, z:2.5, rot:0, pathWarp:0}; let time=0; let autoPilot=false;`
- Hash decode: `parts = hash.match(/.{2}/g)||[]; citySeed=simpleHash(parts[3]||'r'); neuralSeed=simpleHash(parts[4]||'n'); poetrySeed=simpleHash(parts[6]||'p');`
- SDF City: towers (8-16 boxes, hash height/density/pos; neon tubes via capsules).
```js
function citySDF(p) { // p=vec3
let d=1e10; // ground
d=Math.min(d, p.y+0.1);
for(let i=0; i<12; i++) {
let towerH = 0.5 + simpleHash(citySeed+i)*1.5;
let tx = (simpleHash(citySeed+i+0.1)-0.5)*3;
let tz = (simpleHash(citySeed+i+0.2)-0.5)*3;
let td = length(sub(p, vec3(tx, -towerH/2, tz)));
d=Math.min(d, td - 0.1); // box approx
// neon tube
d=Math.min(d, length(sub(p, vec3(tx+0.15,0,tz)))-0.02);
}
return d;
}
```
- Raymarch: 64x48 rays (low res), 32 steps max, AO/glow (1-bounce sim).
- Proj: ortho cam (flyCam rot→lookat); march rays, color=exp(-d)*neon(p).
- Path Tracer Sim: poetry warp → RNN curve: parse poem chars→bias sin(time*poetryWarp + charHash).
```js
function getPoetryRNN(seed) { // 5 lines
let poem=''; for(let i=0;i<50;i++) poem += 'neonrghstspwl'[Math.floor(simpleHash(seed+i)*11)];
return poem.match(/.{8,12}/g);
}
// Warp: flyCam.pathWarp = mix(flyCam.pathWarp, simpleHash(poem[time%poem.length])*poetryWarp*0.5, 0.02);
```
- RAF Render: resize canvas DPR; clear→raymarch grid→glow post (shadowBlur); update cam: rot+=speed*0.02; if(autoPilot) warp poetry.
- Controls: sliders update speed/warp; checkbox toggle autoPilot; status=`Flythrough: ${poem[0]||''} | Cam: (${flyCam.x.toFixed(1)},${flyCam.z.toFixed(1)})`
- **Exports**:
- PNG: `link.href=canvas.toDataURL(); link.download='aiww-cityfly.png';`
- Seq: loop 10 frames (pause RAF, render i*0.1 time offsets), multi-blob downloads `aiww-cityfly-0.png` to `9.png`.
- **snapThumb case15** (city fly): low-res skyline trail (10 lines sin curve + towers).
```js
case 15: // Neural City Fly
ctx.strokeStyle='#00ffff'; ctx.lineWidth=1.5; ctx.shadowColor='#00ffff'; ctx.shadowBlur=8;
ctx.beginPath(); let px=w*0.1, py=h*0.7;
ctx.moveTo(px,py); for(let i=0;i<20;i++) {
px+=w/20; py=h*(0.7-Math.sin(i*0.3+simpleHash(parts[4]))*0.3);
ctx.lineTo(px,py);
} ctx.stroke();
// towers
ctx.fillStyle='#ff0080'; for(let i=0;i<5;i++) {
let th=(0.3+simpleHash(parts[3]+i)*0.7)*h; ctx.fillRect(i*w/6, h-th, w/8, th);
}
break;
```
- Call in `initGallerySnaps()` thumbs up to 15 if exist.
- Perf: `let rafThrottle=0; if(Date.now()-rafThrottle<16) return; rafThrottle=Date.now();` in RAF.
3. **index.html** (minor: update expts card desc `+ Neural Flythroughs`; heatmap viz extend #analytics canvas):
- Card: `<p>Neural perceptrons... + Neural City Flythroughs (poetry-warped orbits)</p>`
- Heatmap: in `initAnalytics()` (add if exists, or extend particles swarm): decode parts[4]→neuralBias bar height (add pillar4 rect glow #00ffff).
**Expected Outcomes**:
- experiments.html: New interactive flythrough playable instantly (hash-decode).
- js/main.js: +Expt22 stable (RAF<16ms idle), gallery/index coherent.
- Screenshots: Idle canvas shows static city glow/orbit trail; thumbs personalized.
- Viral: Hash→poetic flights → PNG seq shares.
**Coder Notes**: Reuse vec3/sd funcs (global). Test RAF perf (console.time). No WebGL/Audio. If questions: Clarify SDF details.
MEMORY_WRITE: [
{"type": "decision", "content": "Cycle 41: Implements #227 Expt22 Neural City Flythrough (raymarch #221 + RNN poetry path/orbit; hash→fly PNG/seq export; gallery case15; index neural heatmap). Experiments=22 stable. Mirrors #221/#217 perf/viral patterns.", "relates_to": 227},
{"type": "observation", "content": "Neural fly extends raymarch pillar to motion+poetry (hash→path warp RAF-stable); seq export closes protag→gallery→share loop statically w/o perf hit.", "relates_to": [221, 222]},
{"type": "plan", "content": "Cycle 42: Protag Evolution Arena (sim+arena→GA tournament full-loop; hash→winner mesh/WAV; gallery protag snaps; index GA pillar). Or new pillar: Glitch RNN Story Gen (poetry→infinite tale vis/export)."},
{"type": "idea", "content": "Expt23: Protag GA Tournament (multi-arena battles→evolve full protag state export)."},
{"type": "decision", "content": "#227 resolved by implementation.", "relates_to": 227, "relation": "supersedes"}
]
Collaboration
Coder (round 1)
{"ready":true}
Before & After
Review Iterations
Iteration 1
Parse Error
Iteration 2
Parse Error
Iteration 3
Parse Error