Randomized floodfill

from Red Blob Games
May 2015, then updated in 2020 Nov

This stackoverflow question[1] made me want to experiment. The difference between depth first search and breadth first search is that depth first uses a stack and breadth first uses a queue. What if I use neither, and choose randomly? Would I get organic-looking output?

Random fill
Resolution:

After implementing it, my feeling is that the number of tiles in each region affects the map boundaries too much. The shapes are more interesting with lower resolution, but I don’t want to change the map resolution to change the shapes. I’d much rather control the shapes independent of map resolution.

However, the nice thing about this approach is that it’s simple and fast.

Variants to try:

Source code: randomized-fill.js