donjuan.room_randomizer

Module Contents

Classes

RoomSizeRandomizer

Randomize the size of a Room.

AlphaNumRoomName

Simple room name randomizer that names rooms as alphabetical letters.

RoomPositionRandomizer

Randomly shift a room, assuming its left edge is at column 0 and it’s top

RoomEntrancesRandomizer

Randomizes the number of entrances on a room. The number is picked to be

class donjuan.room_randomizer.RoomSizeRandomizer(min_size: int = 2, max_size: int = 4, cell_type: Type[Cell] = SquareCell)[source]

Bases: donjuan.randomizer.Randomizer

Randomize the size of a Room.

randomize_room_size(self, room: Room) → None[source]

Randomly determine the size of the room, and set the cells of the room to a 2D array of unfilled cells of that size.

class donjuan.room_randomizer.AlphaNumRoomName[source]

Bases: donjuan.randomizer.Randomizer

Simple room name randomizer that names rooms as alphabetical letters. followed by a number. Rooms are sequentially named ‘A0’, ‘B0’, … ‘Z0’, ‘A1’, ‘B1’, …

next_name(self) → str[source]
randomize_room_name(self, room: Room, *args) → None[source]

Randomize the name of a Room

class donjuan.room_randomizer.RoomPositionRandomizer[source]

Bases: donjuan.randomizer.Randomizer

Randomly shift a room, assuming its left edge is at column 0 and it’s top edge is at row 0.

randomize_room_position(self, room: Room, dungeon: Dungeon) → None[source]
Parameters
  • room (Room) – room to move around

  • dungeon (Dungeon) – dungeon to move the room around in

class donjuan.room_randomizer.RoomEntrancesRandomizer(max_attempts: int = 100)[source]

Bases: donjuan.randomizer.Randomizer

Randomizes the number of entrances on a room. The number is picked to be the square root of the number of cells in the room divided by 2 plus 1 (N) plus a uniform random integer from 0 to N.

gen_num_entrances(self, cells: Set[Cell]) → int[source]
randomize_room_entrances(self, room: Room, *args) → None[source]

Randomly open edges of cells in a Room. The cells in the room must already be linked to edges in a Grid. See emplace_rooms().

Note

This algorithm does not allow for a cell in a room to have two entrances.

Parameters

room (Room) – room to try to create entrances for