2 ms·
Diagonal player movement isn't allowed (from the looks of the article), but wall connections can be diagonal. There's a duality here - if players and enemies co
by penteract 2y ago
Diagonal player movement isn't allowed (from the looks of the article), but wall connections can be diagonal. There's a duality here - if players and enemies could move diagonally, the algorithm could be adapted by only considering horizontal and vertical wall adjacencies (although still looking at the surrounding 8 squares to determine separation of adjacent walls). We're relying on the property "if adding a wall creates an enclosed region, one of the enclosed squares must be move-adjacent to the new wall".
"separated" = "not connected when considering only the 8 neighbors of where you intend to place the new wall; diagonals do count as connections between walls".
In the following example, the walls adjacent to the + are not separated:
+X
X.
In the next example, the walls are adjacent to the + are separated:
X..
.+.
..X
> There was something else in the article that bothered me
Regarding your second point, I think the article changed half way through from assuming the play area is surrounded by a wall to assuming the play area is surrounded by empty space, which I agree is confusing. Either case could be covered by this algorithm - just start with a connected component of wall at the edge of the play area.