CellularGenerator

class CellularGenerator(width: int, height: int, wall, floor, dirs: DIRS, rng: random.Random, dtype: npt.DTypeLike, prob: float)

Bases: MapGenerator

Uses an algorithm based on Conway’s Game of Life to procedurally generate maps.

Parameters:
  • width – The width of the maps to generate

  • height – The height of the maps to generate

  • wall – The value inserted into the array when a tile is a wall

  • floor – The value inserted into the array when a tile is a floor

  • prob – The probability that any given tile will be a wall when randomizing the map

generate_map() npt.NDArray

Generates a new map.

Handles seeding and processing the map automatically.

Returns:

The new map

process_map(working_map: npt.NDArray) None

Processes a randomized map.

This does four iterations of an algorithm which includes seeding walls on tiles that have fewer than 3 walls in their neighborhood, followed by 3 iterations that process the map, but don’t seed new tiles.

Parameters:

working_map – The map to process

rule1_iters: int

The number of iterations for the first algorithm, which seeds new walls

rule2_iters: int

The number of iterations fo the second algorithm, which does not seed walls