sraaphorst / spelunker

Maze generation and solving library
Other
11 stars 2 forks source link

Find connected components #109

Closed sraaphorst closed 6 years ago

sraaphorst commented 6 years ago

We need an algorithm that can find connected components in a maze, and label each cell with a representation of its connected component. This is what will enable us to unite many of the Maze and ThickMaze algorithms together. It will allow:

  1. Easier drawing of Maze where some cells are out of bounds (e.g. through sparsifying): given a start cell and one of more goals (which obviously must be in the same connected component), fill in all cells not in the connected component (or don't, if you wish to be confusing).

  2. This will allow us to simulate a ThickMaze, which has two components (not necessarily connected except in the case of a perfect graph, i.e. walls and floor) in a regular Maze by marking certain transitions as "out of bounds," such as in a ThickMaze moving from a floor to a wall, or in a Maze, moving from one component to another. This should allow us to use multiple algorithms on AbstractMaze directly, if it contains a neighbours method or canMoveFromCell1ToCell2 method.