[英]Disjoint set and maze creation
I am attempting to create a maze using a premade Disjoint set class. 我正在尝试使用预制的不相交集合类创建迷宫。 I have created a Cell class that contains a boolean variable for each of the four walls.
我创建了一个Cell类,其中包含四个壁中每个壁的布尔变量。 The problem is, how do I create a disjoint set of cell objects?
问题是,如何创建不相交的单元格对象集? That way I can union the cells and change the boolean variables accordingly.
这样,我可以合并单元格并相应地更改布尔变量。
http://users.cis.fiu.edu/~weiss/dsaajava3/code/DisjSets.java http://users.cis.fiu.edu/~weiss/dsaajava3/code/DisjSets.java
That is the code for the disjoint set 那是不相交集的代码
A disjoint set data-structure is not suited for this particular problem. 不相交的集合数据结构不适合此特定问题。
Attempting to force your solution to use it is just going to give you poor code and a bad design. 试图强迫您的解决方案使用它只会给您糟糕的代码和糟糕的设计。
Not to mention that there is a much simpler, more elegant solution. 更不用说有一个更简单,更优雅的解决方案。
In order to generate a perfect (one unique path between any two points) maze: 为了生成一个完美的(任意两点之间的唯一路径)迷宫:
All you need is a grid, and a list. 您只需要一个网格和一个列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.