Identifies all connected components of solid cells that are not
reachable from the supplied anchors.
Algorithm
Mark every cell reachable from an anchor via 4-connected BFS
through solid (non-zero) cells; these are the "anchored" cells.
Walk every cell of the bitmap. For each unvisited solid cell that
is not anchored, run a second BFS to collect its connected
component as one Island.
Performance
O(width × height). The architecture doc § Flood fill targets ~5 ms
on a 4 MB world; this implementation is per-cell getPixel and
matches that ballpark. Optimization to iterate chunks directly is
possible later if profiling shows it's needed.
The two BFS passes are intentional: it lets us treat "anchored" as a
boolean mask rather than a sentinel value, which makes the second
pass simpler and avoids accidentally claiming anchored cells as
islands.
Identifies all connected components of solid cells that are not reachable from the supplied anchors.
Algorithm
Performance
O(width × height). The architecture doc § Flood fill targets ~5 ms on a 4 MB world; this implementation is per-cell
getPixeland matches that ballpark. Optimization to iterate chunks directly is possible later if profiling shows it's needed.The two BFS passes are intentional: it lets us treat "anchored" as a boolean mask rather than a sentinel value, which makes the second pass simpler and avoids accidentally claiming anchored cells as islands.