Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Disjoint sets.

1) Each cell in the maze is a set. 2) Randomize walls. Check if wall to be removed are already in the same set. Merge the set if wall is removed. 3) Repeat until entire maze is in one set.

DFS seems a bit odd for generation. For generating a solution, it would be what I would do.



I'm told DFS tends to produce easier mazes in the sense that after you've made a bit of progress, false paths typically end more and more quickly.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: