Maze generator & solver · deepseek-v4-flash-0731
Generate a random maze with the recursive-backtracker algorithm on a canvas, then animate an A-star or BFS solver finding the path from start to finish.
transcript · 9 messages
thinking
Let me build a single-page web app with a maze generator and solver. Let me create index.html. I'll use recursive backtracker (DFS) for maze generation on a canvas, then animate a BFS solver. Let me write the code.
/workspace/index.html (16562 bytes)Successfully wrote 16562 bytes to /workspace/index.html
thinking
Let me verify the file exists and maybe check for obvious JS errors. There was a reference to Math42() as a hack — it's fine but ugly. Let me just make sure the initial boot works. Actually let me double check the generate animation logic. The generate() runs dfs() first recording snapshots, then animates. That's fine. One issue: during generation animation, dfs already fully computed grid but we restore snapshots. The drawGrid call uses `newAnimationMap(grid)` for cells plus front set. Fine. Let me simplify - remove the odd Math42. Let me just quickly verify JS syntax with node.
Let me verify the file is valid and check the JS syntax.
{"command":"cd /workspace && node -e \"\nconst fs=require('fs');\nconst html=fs.readFileSync('index.html','utf8');\nconst m=html.match(/<scrJS OK, length 11754 -rw-r--r-- 1 node node 16574 Jul 31 18:33 index.html
thinking
The JS is valid. Let me clean up a couple of ugly hacks: Math42() and the early termination comment. Let me replace Math42 with newAnimationMap(grid) directly in solve().
JS is valid. Let me clean up a hacky placeholder and simplify.
{"path":"/workspace/index.html","edits":[{"oldText":" pathLen.textContent = len;\n drawGrid(Math42(), openSet, closedSet, pathSuccessfully replaced 3 block(s) in /workspace/index.html.
{"command":"cd /workspace && node -e \"\nconst fs=require('fs');\nconst html=fs.readFileSync('index.html','utf8');\nconst m=html.match(/<scrJS OK
Done. Here's `/workspace/index.html` — a self-contained single-page app (no external resources). **What it does:** - **Generation:** The recursive-backtracker (DFS) algorithm builds the maze with an explicit stack, but the process is *animated* — each carve step is snapshotted and played back, showing the DFS frontier (blue-gray stack) as it carves tunnels through the grid. - **Solving:** BFS (breadth-first) explores from the start with a FIFO open set — you can watch the blue open-set frontier expand into the purple explored region until it reaches the finish, then the pink solution path is traced back. **Controls:** - **Columns / Rows:** pick maze dimensions (15×15 up to 50×30) - **Speed:** Slow → Turbo, or "Instant" to skip animation - **Generate Maze:** regenerates a new random maze with animation - **Solve:** runs the animated BFS solver **Status bar** tracks cells carved, cells visited, and final path length; a legend explains the colors. Start (cyan, top-left) and finish (pink, bottom-right) are marked clearly, and canvas sizing auto-adjusts with wall thickness accounted for. The code is fully inline (`<style>` + `<script>`) with no CDNs or network calls, so it runs completely sandboxed. Just open it in a 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
EVALUATION
Maze renders correctly but solve/generate never triggers via generic click; requires clicking specific 'Solve'/'Generate' buttons which weren't tested.
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.