What's a good algorithm to generate a maze?

后端 未结 9 1491
囚心锁ツ
囚心锁ツ 2020-11-27 09:55

Say you want a simple maze on an N by M grid, with one path through, and a good number of dead ends, but that looks \"right\" (i.e. like someone made it by hand without too

9条回答
  •  萌比男神i
    2020-11-27 10:22

    I prefer a version of the Recursive Division algorithm. It is described in detail here.

    I will give a quick overview:
    The original recursive division algorithm works as follows. First, start with an empty area for the maze. Add one straight wall to divide the chamber in two, and put one hole in that wall somewhere. Then, recursively repeat this process on each of the two new chambers until the desired passage size is reached. This is simple and works well, but there are obvious bottlenecks which make the maze easy to solve.

    The variant solves this problem by drawing randomized, "curved" walls rather than straight ones, making the bottlenecks less obvious.

提交回复
热议问题