oneshotlm
Compare all models on this prompt →

Reaction-diffusion · glm-5

Output generated Cost / run $0.0157 Runtime 89.7s

Prompt for this run

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 ↗

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

modelglm-5
vendorZ.ai · GLM
harnesspi-agent
generated2026-07-22

METRICS

runtime89.7s
tokens in8.9k
tokens out6.2k
cached2.9k
cost / run$0.0157
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 me to create a Gray-Scott reaction-diffusion simulation that generates Turing patterns. This is a classic system that produces organic, biological-looking patterns.

Key components needed:
1. Gray-Scott model equations:
   - ∂u/∂t = Du∇²u - uv² + f(1-u)
   - ∂v/∂t = Dv∇²v + uv² - (f+k)v

2. Parameters that produce nice patterns:
   - Du, Dv (diffusion rates)
   - f (feed rate)
   - k (kill rate)

3. Implementation:
   - Two 2D arrays for u and v concentrations
   - Laplacian calculation using finite differences
   - GPU-accelerated version using WebGL would be ideal for real-time
   - Mouse interaction to seed new growth (add v where clicked)

4. Canvas rendering:
   - Map u or v values to colors
   - Real-time animation loop

Let me create a WebGL-accelerated version for smooth real-time performance, with mouse interaction to seed patterns.

I'll create a real-time Gray-Scott reaction-diffusion simulation with WebGL for smooth performance and mouse interaction.

→ write /workspace/index.html (23209 bytes)
toolResult

Successfully wrote 23209 bytes to /workspace/index.html

assistant
thinking
I've created a complete Gray-Scott reaction-diffusion simulation. Let me verify the file was created correctly.

I've created a complete Gray-Scott reaction-diffusion simulation with the following features: **Core Simulation:** - WebGL2-accelerated simulation running 8 steps per frame for smooth real-time performance - Gray-Scott equations: ∂u/∂t = Du∇²u - uv² + f(1-u) and ∂v/∂t = Dv∇²v + uv² - (f+k)v - Laplacian computed using a 3x3 stencil for accurate diffusion **Interactive Features:** - **Click and drag** to seed new growth patterns with organic-looking results - **Adjustable brush size** for different seed scales - **Real-time parameter control** for feed rate and kill rate **Presets Included:** - **Mitosis** - Classic cell-division-like patterns - **Coral** - Branching coral structures - **Waves** - Ripple-like wave patterns - **Spots** - Leopard-spot formations - **Maze** - Complex labyrinthine patterns - **Worms** - Writhing organic worm-like structures **Keyboard Controls:** - **Space** - Pause/resume simulation - **R** - Reset with new random seed pattern **Visual Polish:** - Beautiful organic color palette with smooth gradients - Subtle vignette effect - Glow highlights on concentration peaks - FPS counter in corner The simulation starts with randomly placed seed clusters that grow and evolve into complex Turing patterns. Click anywhere to add new seeds and watch them interact with existing patterns!