oneshotlm
Compare all models on this prompt →

Conway's Game of Life · grok-4.20

Run Conway's Game of Life on a full-screen canvas grid with click-and-drag to toggle cells, plus play/pause, step, randomize, and clear controls.

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

Run Conway's Game of Life on a full-screen canvas grid with click-and-drag to toggle cells, plus play/pause, step, randomize, and clear controls.

assistant
thinking
The task is to build a single-page web app for Conway's Game of Life. It must be in one self-contained file named index.html with CSS in <style> and JS in <script>, no external resources.
The task is to build a single-page web app for Conway's Game of Life in one self-contained index.html file with CSS in <style> and JS in <script>. It needs to be full-screen canvas grid, click-and-drag to toggle cells, and controls for play/pause, step, randomize, clear.

 - Full-screen canvas
  - Click-and-drag to toggle cells
  - Controls: play/pause, step, randomize, clear
  - Grid based on rules: underpopulation, overpopulation, reproduction
  - Use 2D array for grid state
  - Reasonable grid size like 100x60 based on canvas
  - Cell size ~8px
  - Play/pause, step, randomize, clear buttons
  - Maybe speed slider, generation counter
  - Dark theme
  - Canvas with grid lines
  - Instructions
  - Use requestAnimationFrame
  - Fixed interval for simulation
 - Two arrays for current/next gen
  - Neighbor count with 8 directions
  - Toroidal wrap around
  - Colors: dark bg, alive in green/cyan
  - HTML: body with canvas, div for controls
  - Absolute positioned controls
  - Navbar at top with title, buttons - Canvas fills rest
  - Footer instructions
  - Keyboard: space for play/pause
  - Dynamic grid on resize: cols = floor(width/cellSize), rows = floor(height/cellSize)
  - Adjust canvas size accordingly
  - Init grid on load/resize
  - Fixed cellSize=8 - 2D array boolean or 0/1
  - Compute next gen based on rules
  - Mouse: mousedown toggle, mousemove if dragging toggle (paint mode)
  - requestAnimationFrame loop: draw grid, check time for update if running
  - Buttons: toggle running, step ( 1 gen), randomize (random live), clear (all dead)
  - Generation counter
  - Speed slider (interval ms)
  - Style: dark, buttons nice, hover effects
  - No external resources
  - Self-contained
  - One file
  - Canvas full screen
  - Overlay controls - Layout: body margin0 overflow hidden
  - Canvas display block
  - Controls fixed top
  - Flexbox for buttons
  - Canvas height calc
  - Resize listener adjust cols rows, recreate grid
  - Preserve pattern? Simple recreate
  - Draw: fill bg, fill alive cells
 - Optional grid lines
  - getNeighbors with mod for wrap
  - Swap grid and nextGrid refs
  - Copy values if needed
  - handleMouse: calc x y, toggle cell
  - isDragging flag
  - Add event listeners
  - Animation loop: rAF, draw, time check update
  - Variables: grid, nextGrid, cols, rows, cellSize, running, gen, interval
  - createGrid func
  - draw func
  - update func
  - getNeighbors func
  - mouse handlers
  - button handlers
  - resize handler
  - HTML structure
    - <html>
    - <head>
    - <style> dark theme, buttons, canvas
    - </style>
    - </head>
    - <body>
    - <div id="controls">
    - <h1>Conway's Game of Life</h1 - buttons: play/pause, step, randomize, clear, slider, gen counter
    - </div>
    - <canvas id="canvas"></canvas>
    - <div id="instructions">Click/drag to toggle. Space to play/pause.
bash {"command":"ls"}
toolResult

(no output)

assistant
thinking
The task is to build a single-page web app for Conway's Game of Life. It must be in one self-contained file named index.html with CSS in <style> and JS in <script>. No external resources.
The task is to build a single-page web app for Conway's Game of Life in one self-contained index.html file with CSS in <style> and JS in <script>. It needs to be full-screen canvas grid, click-and-drag to toggle cells, and controls for play/pause, step, randomize, clear.

 I need to create this app. Since it's a coding task, I have to write the HTML, CSS, and JS code that implements this.

  First, structure the HTML: a canvas element for the grid, and some buttons for controls, maybe a div for status.

  Make the canvas full-screen, so use 100vh or something, but in JS set width and height to window dimensions.

  Use CSS to make canvas display block, full size.

  For controls, use a fixed position div with buttons.

  Let's sketch the code.

  HTML:

  <!DOCTYPE html>

  <html lang="en">

  <head <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Conway's Game of Life</title>

  <style>

  body { margin: 0; overflow: hidden; background: black; }

  canvas { display: block; }

  #controls { position: absolute; top: 10px; left: 10px; z-index: 10; background: rgba(0,0,0,0.5); padding: 10px; border-radius: 5px; }

  button { margin 5px; }

  </style>

  </head>

  <body>

  <canvas id="canvas"></canvas>

  <div id="controls">

  <button id="playPause">Play</button>

  <button id="step">Step</button>

  <button id="randomize">Random 50%</button>

  <button id="clear">Clear</button>

  <label for="speed">Speed: </label><input type="range" id="speed" min="1" max="20" value="10">

  </div>

  <script>

// JS code here

  </script>

 </body>

  </html>

  Yes, something like that.

  Now, in script:

  const canvas = document.getElementById('canvas');

  const ctx = canvas.getContext('2d');

  const playPauseBtn = document.getElementById('playPause');

  const stepBtn = document .getElementById('step');

  const randomizeBtn = document.getElementById('randomize');

  const clearBtn = document.getElementById('clear');

  const speedSlider = document.getElementById('speed');

  let cellSize = 10; // can make variable but fixed for now 10

  let cols, rows;

  let grid = [];

  let running = false;

  let generation = 0;

  let simInterval = null;

  let speed = 10; // gens per second

  function resizeCanvas() {

    canvas.width = window.innerWidth;

    canvas.height = window .innerHeight;

    cols = Math.floor(canvas.width / cellSize);

    rows = Math.floor(canvas.height / cellSize);

    initGrid();

  }

  function initGrid() {

    grid = Array.from({length: rows}, () => Array(cols).fill(0));

  }

  function draw() {

 ctx.fillStyle = 'black';

  ctx.fillRect(0,0,canvas.width,canvas.
write index.html (17810 bytes)
toolResult

Successfully wrote 17810 bytes to index.html

assistant
thinking
The task is complete. I have created a single self-contained index.html file with Conway's Game of Life.

The file `index.html` has been created with a complete, self-contained implementation of Conway's Game of Life (full-screen canvas, click/drag to paint/erase cells with mouse or touch, play/pause/step/randomize/clear controls, speed slider, keyboard shortcuts, generation counter, toroidal grid, retro styling). Open it in a browser to run.

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

modelgrok-4.20
vendorxAI · Grok
harnesspi-agent
generated2026-08-01

EVALUATION

3/5 working

Game of Life grid with UI panel; drag draws cells, space toggles play running the simulation (generation counter increases), but grid activity is sparse/minimal.

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 motion0.3%
on click0.0%
on drag0.4%
on wheel0.0%
on enter + space0.8%
on arrow keys0.3%
on w/a/s/d0.2%
frame spread14.5 / 255
console errors1
js errors none

METRICS

runtime88.8s
tokens in5.6k
tokens out13k
cached3.2k
cost / run$0.0389