Skip to content

Commit a9a0cc2

Browse files
committed
pick random cell for wilsons algorithm
1 parent 5233486 commit a9a0cc2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

components/visuals/mazes/components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function wilsonsAlgorithm(maze: Maze, ctx: CanvasRenderingContext2D, cance
6666
const visited = new Set<Cell>();
6767

6868
// Choose one cell arbitrarily, add it to the maze, and mark it as visited
69-
const startCell = maze.getCell(0, 0);
69+
const startCell = randomMember(maze.cells.flat())
7070
visited.add(startCell);
7171
unvisited.delete(startCell);
7272

posts/generating-mazes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const unvisited = new Set<Cell>(maze.cells.flat());
130130
const visited = new Set<Cell>();
131131

132132
// Choose one cell arbitrarily, add it to the maze, and mark it as visited
133-
const startCell = maze.getCell(0, 0);
133+
const startCell = randomMember(maze.cells.flat())
134134
visited.add(startCell);
135135
unvisited.delete(startCell);
136136

0 commit comments

Comments
 (0)