Maximize boid count at 60 FPS (browser-measured, clustered steady state).
The evaluate command launches a browser, ramps boids, and reports max_boids.
- Read
shader.wgslandsimulation.js - Pick ONE optimization for the
flock_radiusfunction (or supporting code) - Edit the file(s)
- VALIDATE before committing:
- Run:
PATH=$HOME/.deno/bin:$PATH deno eval --unstable-webgpu "const a=await navigator.gpu.requestAdapter();const d=await a.requestDevice();const m=d.createShaderModule({code:await Deno.readTextFile('shader.wgsl')});const i=await m.getCompilationInfo();if(i.messages.length>0){console.log('SHADER ERROR');Deno.exit(1)}console.log('OK');d.destroy()" - If it prints SHADER ERROR: undo your edit and try something else. Do NOT commit broken code.
- Run:
git add shader.wgsl simulation.js && git commit -m "experiment: <description>"- Run:
python3 evaluate.py 2>/dev/null - Parse the last line for
max_boids: NNNNN - If the result is 0 or contains "error": the experiment BROKE something.
git revert --no-edit HEADimmediately. - If max_boids improves over previous best -> KEEP, append result to
results_classic_perf.tsv - If max_boids does not improve ->
git revert --no-edit HEAD, append result toresults_classic_perf.tsv - After reverting, verify the app still works by running the validate command from step 4.
- REPEAT. Do NOT pause. Loop until interrupted.
shader.wgslsimulation.js
Focus on the flock_radius compute kernel in shader.wgsl (and pipeline/grid
config in simulation.js if it is editable).
The flock function in shader.wgsl is LOCKED. Do NOT change it in any way.
Do NOT rename, rewrite, reorder, or touch any line inside flock.
bench_browser.js,evaluate.py,render.wgsl,renderer.js,index.htmldashboard.py,serve.py,program.md,scheduler.py,schedule_config.json- Do NOT add roost attractors or global orbit forces
flock_radiusmust produce correct flocking (separation, alignment, cohesion)- Boid struct: 64 bytes (16 floats) -- don't change the layout
- Billboard additive + radius neighbor mode is what's benchmarked
- Do NOT modify
flockunder any circumstances
If you edit simulation.js, these lines MUST remain exactly as they are:
- Grid formula:
Math.cbrt(numBoids / 4)— do NOT change to /8 or any other value - Visual range clamp:
cellSize * 1.4— do NOT change to 0.8 or any other value - Frame scheduling: odd frames drift, even frames full flock — do NOT add mod128 or other skip patterns
- Auto-range stats:
if (autoRangeEnabled &&— do NOT disable withif (false &&
Before committing ANY experiment, verify these are preserved:
- Heading update: boids_dst[i].heading MUST be written with a smoothly tracked direction based on velocity. Without this, boids face the wrong way.
- size_factor copy: boids_dst[i].size_factor = boid.size_factor MUST be written.
- 27-cell neighbor search: The flock function MUST search neighboring grid cells (3x3x3), not just the own cell. Own-cell-only breaks flocking.
- Separation + Alignment + Cohesion: All three forces must be computed. Removing any one breaks the flocking behavior.
- If a drift() pass exists: It MUST copy heading, size_factor, and all viz metrics (speed, neighbor_count, etc.) from src to dst.
If you remove any of these for performance, the experiment WILL be reverted because the visual result will be broken even if the benchmark passes.