oneshotlm
Compare all models on this prompt →

Reaction-diffusion · qwen3.7-plus

Run a Gray-Scott reaction-diffusion simulation on a canvas that grows organic Turing patterns in real time, with the mouse seeding new growth.

⛨ sandboxed Open in new tab ↗
transcript · 4 messages
user

Run a Gray-Scott reaction-diffusion simulation on a canvas that grows organic Turing patterns in real time, with the mouse seeding new growth.

assistant
thinking
The user wants a Gray-Scott reaction-diffusion simulation as a single-page web app. Let me think about what this needs:

1. Gray-Scott model parameters: du, dv (diffusion rates), f (feed rate), k (kill rate)
2. Two chemical fields: U and V
3. The simulation equations:
   - du/dt = du * ∇²u - u*v² + f*(1-u)
   - dv/dt = dv * ∇²v + u*v² - (f+k)*v
4. Mouse interaction to seed new growth (add V to the field)
5. Visualization on canvas - color the pixels based on V concentration
6. Real-time animation

I'll use a two-buffer approach for the Laplacian computation. Let me write a performant implementation:

- Use two sets of Float32Arrays for U and V (current and next state)
- Compute Laplacian using the standard 5-point stencil (or 9-point for better patterns)
- Render V values to canvas using ImageData
- Use requestAnimationFrame for real-time animation
- Mouse move adds V values at the cursor position

For good-looking patterns, I'll use parameters like:
- F = 0.055, k = 0.062 (spots pattern)
- Or F = 0.035, k = 0.065 (stripes/labyrinths)

I'll go with a nice organic pattern parameter set and let the user possibly adjust them. Let me implement this with a 9-point Laplacian for smoother results.

For performance, I'll use a reasonable grid size and render every pixel. Let me scale the canvas to fill the window.

Let me write this as a complete, self-contained HTML file.
write /workspace/index.html (11285 bytes)
toolResult

Successfully wrote 11285 bytes to /workspace/index.html

assistant
thinking
Done. Let me verify the file is there.

The file is ready at `/workspace/index.html`. Here's what it does: **Simulation** - Implements the Gray-Scott reaction-diffusion model with two chemicals (U, V) on a 9-point Laplacian stencil for smooth, organic results - Default parameters (f=0.055, k=0.062) produce **growing spots** that split and merge — classic Turing patterns - Runs multiple simulation steps per frame for real-time speed **Interaction** - **Click & drag** anywhere to inject chemical V, seeding new organic growth patterns - Strokes are interpolated so dragging fast still produces continuous trails - Touch support included for mobile **Controls panel** (top-left) - **Feed (f)** — adjusts the feed rate; slide to explore different pattern regimes (spots ↔ stripes ↔ labyrinths) - **Kill (k)** — adjusts the kill rate; lower values give bigger, slower structures - **Brush** — size of the seed region when clicking - **Speed** — simulation steps per animation frame - **Reset** — clears and re-seeds the canvas **Visuals** - V concentration mapped through a 256-entry color LUT: deep indigo → teal → cyan → warm white, giving a bioluminescent ocean feel - A color LUT ensures rendering stays fast even at high grid sizes

TAKE IT TO CODE

A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.

RUN

modelqwen3.7-plus
vendorQwen
harnesspi-agent
generated2026-07-22

EVALUATION

4/5 working

Gray-Scott reaction-diffusion grows organic maze-like Turing patterns that evolve continuously and react to clicks/drags/wheel.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion2.5%
on click6.0%
on drag10.0%
on wheel5.0%
on enter + space0.4%
on arrow keys5.2%
on w/a/s/d0.9%
frame spread14.7 / 255
console errors0
js errors none

METRICS

runtime99.0s
tokens in8.0k
tokens out5.1k
cached0
cost / run$0.0091