Wednesday, January 19, 2022

[yokcmzvw] partitioning into random shaped rooms

pick a random cell on a grid.  if the cell is already part of a region, pick another cell.  if the cell is adjacent to a region, assign it to that region.  if the cell is adjacent to two or more regions, assign it to the smallest region, picking one at random if a tie for smallest size.  if the cell is adjacent to no regions, it is the seed for a new region.  repeat until there are no unassigned cells.

what sort of pattern of regions results?  what is the distribution of region areas?  what is the distribution of number of neighbors?

it is possible for a region to be completely surrounded by another region.

run a maze generation algorithm on the graph of adjacencies between regions: some region boundaries get doorways.  (aesthetically, where on a boundary should a door go?)  this results in a maze of rooms, with each room having a distinct shape, which can make a maze more entertaining.

further operations: regions merging, dividing.  a region might transfer a border cell to an adjacent region, modeling warfare.

No comments :