oneshotlm
Compare all models on this prompt →

Reaction-diffusion · gemini-3.1-flash-lite-preview

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
**Developing the Foundation**

I'm focusing on the core structure now, building the foundation for the Gray-Scott simulation within a single HTML file. My emphasis is on real-time rendering, mouse seeding, and generating those organic Turing-like patterns. I'm leveraging HTML5 Canvas and JavaScript to achieve this, keeping an eye on avoiding dependencies or network requests to remain a self-contained, single-file solution.


**Defining the Core Dynamics**

I'm now diving into the Gray-Scott equations. I've broken down the key components: the U and V chemicals, their reaction pathways, and the core reaction dynamics with feed and kill rates. I need to define the 2D grid structure and how I'll handle diffusion and interactions via the Laplacian calculation. The next steps will involve initialization, creating seed and animation functions using `requestAnimationFrame`.


**Constructing the Canvas**

I'm now implementing the necessary HTML elements and associated JavaScript for the simulation. This includes setting up the `<canvas>` element, ensuring responsive sizing to fit the screen, and establishing the foundational JavaScript structures. I'm focusing on initializing the arrays using `Float32Array` for performance, and then writing update and draw functions for reaction-diffusion, and rendering the pixels directly to the canvas using `ImageData`.

I'm also setting up a mouse listener for seeding. To maintain a reasonable performance, I'm aiming for a grid size like 100x100 or 200x200. I need to handle scaling the canvas for responsiveness too.

**Addressing Computation & Boundaries**

I am now addressing some key performance considerations as well as implementing core features. I've chosen to use typed arrays (`Float32Array`) to boost performance. Additionally, I will use two sets of grids (`current`, `next`) that I will swap every frame. I also have chosen to implement the Laplacian Calculation with wrap around boundary conditions. The ideal parameters look like F = 0.037, k = 0.06.


write index.html (4262 bytes)
toolResult

Successfully wrote 4262 bytes to index.html

assistant

The Gray-Scott reaction-diffusion simulation is now ready in `index.html`. You can open this file in any web browser to see the real-time simulation. ### Features * **Performance:** Uses high-speed pixel buffer manipulation to maintain a fluid frame rate. * **Interaction:** Click and drag on the canvas to "paint" the second chemical (V) onto the grid, seeding new, self-organizing pattern growth. * **Self-Contained:** Everything, including the logic and rendering, is packaged into a single HTML file—no external dependencies or network requests needed. You can now open `index.html` in your browser.

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

modelgemini-3.1-flash-lite-preview
vendorGoogle
harnesspi-agent
generated2026-07-22

EVALUATION

4/5 working

Gray-Scott reaction-diffusion renders evolving Turing patterns, self-animating, and reacts to click/drag/wheel seeding; arrows/wasd have no effect.

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 motion3.3%
on click24.6%
on drag25.7%
on wheel17.1%
on enter + space8.5%
on arrow keys0.0%
on w/a/s/d0.0%
frame spread32.7 / 255
console errors0
js errors none

METRICS

runtime10.0s
tokens in5.3k
tokens out2.6k
cached0
cost / run$0.0052