donjuan.dungeon_randomizer

Module Contents

Classes

DungeonRandomizer

Randomize a dungeon by first creating rooms and then applying

class donjuan.dungeon_randomizer.DungeonRandomizer(room_entrance_randomizer: Optional[Randomizer] = None, room_size_randomizer: Optional[Randomizer] = None, room_name_randomizer: Optional[Randomizer] = None, room_position_randomizer: Optional[Randomizer] = None, max_num_rooms: Optional[int] = None, max_room_attempts: int = 100)[source]

Bases: donjuan.randomizer.Randomizer

Randomize a dungeon by first creating rooms and then applying room size, name, and position randomizers to sequentially generated rooms.

Parameters
  • room_entrance_randomizer (Optional[Randomizer]) – randomizer for the entrances of a room. If None then default to a RoomEntrancesRandomizer.

  • room_size_randomizer (Optional[Randomizer]) – randomizer for the room size. It must have a ‘max_size’ attribute. If None then default to a RoomSizeRandomizer.

  • room_name_randomizer (Optional[Randomizer]) – randomizer for the room name. If None default to a AlphaNumRoomName.

  • room_position_randomizer (Optional[Randomizer]) – randomizer for the room position. If None default to a RoomPositionRandomizer.

  • max_num_rooms (Optional[int]) – maximum number of rooms to draw, if ``None` then default to the max_room_attempts. See DungeonRoomRandomizer.get_number_of_rooms() for details.

  • max_room_attempts (int, optional) – default is 100. Maximum number of attempts to generate rooms.

get_number_of_rooms(self, dungeon_n_rows: int, dungeon_n_cols: int) → int[source]

Randomly determine the number of rooms based on the size of the incoming grid or the max_num_rooms attribute, whichever is less.

Parameters
  • dungeon_n_rows (int) – number of rows

  • dungeon_n_cols (int) – number of columns

randomize_dungeon(self, dungeon: Dungeon) → None[source]

Randomly put rooms in the dungeon.

Parameters

dungeon (Dungeon) – dungeon to randomize the rooms of