I've got an algorithm that generates a cave procedurally, the map is modeled in the data as a 2d array of 0s (empty space) and 1s (wall). The algorithm works just fine, but I've got quite some isolated small caves on the scene, which I would like to avoid.
That's how the map looks that gets generated. Is there some efficient algorithm to remove the black holes in the white wall sections? I was thinking of something like:
For every closed cave, check if there is a bigger cave and if so, close it.
But that seems insanely inefficient since I'd have to loop over the map a lot in order to do this for all small caves.