App · TypeScript
Drunken Cockroach Path
Seeded random walk and backtracking tour of an 8x8 board on a canvas. TypeScript, Vite, Vitest.
Why it exists
The original (September 2024) was a first graphics program: a grid, a recursive search and graphics.h calls. It only ran on a Windows machine with an old graphics library, so nobody could open it. Porting it was a way to keep the idea, make it something a reviewer can open in one click, and learn what the old code actually did: the README claimed a random walk and a Knight's Tour, and the code was neither (see below).
What it does
- 01
Board size. 3x3 to 12x12 cells per side (8x8 by default), kept in the share link as n. The tour solves every start cell of every size in that range (measured 2026-10-23: worst 51 ms).
- 02
Tour mode. a backtracking search finds a path through every cell and the board draws it step by step.
- 03
Random walk mode. one step up, down, left or right per tick, drawn uniformly among the moves that stay on the board.
- 04
Seeded and replayable. a seed (0 to 4294967295) fixes every random choice, so a run can be repeated or shared as a link.
- 05
Playback controls. Start, Pause and Resume, a single Step, Reset, and a speed slider from 1 to 200 steps per second.
- 06
Live counters. steps taken, cells visited out of the board's total, the current position, and the step at which a random walk first covered every cell.
Next
Hand Gesture Volume Control