Pixel Dungeon Wiki
Advertisement

The floor generating algorithm governs the generation of every floor except floor 10, 15, 20, 25 and 26 as these floors use a set level layout. The floor generation itself is broken down into 3 steps: generating individual rooms, putting the rooms together and placing water, grass, and traps. Afterwards, the floor is populated with items and enemies.

Generating rooms[]

The algorithm starts by generating individual rooms.

Standard Rooms[]

These rooms make up most of the floor. Every floor must have an entrance and exit room as well as quest related rooms if a specific quest takes place on that floor. The number of remaining standard rooms determined by region and increased if the floor is large. Individual rooms have a fixed weight (5 or 10 for common rooms, 1 for uncommon rooms), most common rooms are region-specific.

Special Rooms[]

Special rooms are chosen using deck system, with the deck alternating between rooms more likely to contain consumables (garden, magic well room, crystal path room, runestone room, storage room, library, toxic gas room, room of traps, eternal fire room, treasury room) and rooms more likely to contain equipment (crystal vault, flooded vault, crystal choice room, altar room, crypt, statue room, sentry room, weak floor room, armory). However, there are some additional restrictions:

  • There is never more than 1 room which requires a potion to "solve" on a given floor
  • There is never more than 1 room which requires a Crystal Key on a given floor
  • A weak floor room can never generate on a floor just above the boss floor

Additionally, there are also special rooms which are forced to generate on certain floors:

  • A quest related room always appears on a floor with a respective quest
  • A spawner room appears on every Demon Halls floor
  • A shop always appears on floor 6, 11, and 16
  • A pit room always appears on a floor if there is a weak floor room on a previous floor
  • A single laboratory appears in every region

The number of special rooms generated is determined by the region the floor is in and increased if the floor is large. It doesn't include quest related rooms, spawner rooms, pit rooms and shops.

Hidden Rooms[]

Each floor can have a single hidden room. In total, there are 2 to 3 hidden rooms generating in each region. A floor with many secrets always generates with an additional hidden room, allowing for 2 hidden rooms to appear on the same floor. Floor 5 always generates with the Rat King's room as a hidden room. Hidden rooms can't appear on floor 1. On other floors, hidden rooms are chosen using a deck system.

Building the floor[]

At first, standard rooms are placed to form either the loop or figure eight layout, figure eight layout floors always have the largest standard room in the center. Entrance and exit are always a part of the main path and never directly connected. Additional standard rooms are connected to the main path. Special rooms and hidden rooms are then connected to the standard rooms. Rooms can be connected to each other directly or through a hallway, hidden rooms can be connected through a small maze.

Standard rooms have at least one entrance that isn't hidden and they must be connected to an entrance through a path which doesn't involve hidden doors. Special rooms have one entrance which is never hidden but can be locked or barricaded. Hidden rooms have one hidden entrance.

If two standard rooms are placed right next to each other, the wall between them may be removed, merging the room. In caves, the wall can also be replaced with a chasm. Standard rooms can merge with a single other room, but this limit is removed for giant rooms (bigger than 12x12).

Placing random terrain features[]

After the floor is put together, the game randomly places water and grass patches and traps. The frequency of these features depends on region and can be increased by level feelings. Visible traps are as common as hidden ones on most floors and four times as common on floors with extra traps. Permanent traps, auto-aiming traps and rockfall traps never generate in hallways to not block the player. Some rooms already generate with grass, water or traps or prevent random traps inside them entirely.

Item placement[]

Every non boss floor (except 26) contains randomly generated items in addition to room specific loot. It also contains items crucial to survival (food), progression (Scrolls of Upgrade and Potions of Strength) or overcoming certain obstacles on that floor, which are forced to generate in certain quantity.

Prize items[]

The game always generates:

  • 2 Potions of Strength in every chapter (never in the same depth).
  • 3 Scrolls of Upgrade in every chapter (never in the same depth; only 1 - 2 scrolls are generated if Forbidden Scrolls challenge is enabled).
  • 1 Arcane Stylus in every chapter.
  • 1 random food item on every floor (2 if the floor is large).
  • 1 Torch on every dark floor, 2 torches on every floor in the Demon Halls.
  • 1 Rose Petal on every 2 floors if the Hero has identified uncursed dried rose in their inventory upon level generation.
  • 1 Stone of Intuition on floor 1 to 3.
  • 1 Stone of Enchantment in chapter 2 to 4.
  • 1 Arcane Catalyst in chapter 1.

Additional items generated to allow player reach locked or otherwise inaccessible loot:

  • 1 Crystal Key if a crystal vault room or crystal choice room has generated on the floor.
  • 3 Crystal Keys if a crystal path room has generated on the floor.
  • 1 Golden Key for every locked chest that has generated on the floor.
  • 1 Iron Key for every locked door which has generated on the floor.
  • 1 Potion of Levitation if a room of traps or a hidden room with 4 golden chests generates on the floor.
  • 1 Potion of Liquid Flame for each barricaded room that has generated on the floor.
  • 1 Potion of Invisibility if a flooded vault has generated on the floor.
  • 1 Potion of Haste if a red sentry room has generated on the floor.
  • 1 Potion of Frost if an eternal fire room has generated on the floor.

These items can generate scattered in standard rooms just like random items or as loot in certain special rooms (e.i. Potions of Strength can appear in Laboratory).

Random items[]

Each floor contains 3 (60 %), 4 (30 %) or 5 (10 %) randomly generated items scattered in standard rooms.

Item Weight Chance
Gold pile 10 28.57 %
Random scroll 8 22.86 %
Random potion 8 22.86 %
Random missile weapon or armor 3 8.57 %
Random weapon 2 5.71 %
Random wand 1 2.86 %
Random runestone 1 2.86 %
Random seed 1 2.86 %
Random ring or artifact 1 2.86 %

The item generator uses a deck system; whenever it rolls a certain item, its weight is reduced by 1. This continues until there are no items left, then the weights are restored to default values. This means that in every 35 randomly generated items there will always be 1 ring or artifact, 2 weapons, 8 potions etc. With 20 floors containing randomly generated items and 3 to 5 items being generated per floor, the game will likely exhaust the item pool twice during each run.

Tier distribution[]

For tiered items, tier is calculated by the following table.

T2 T3 T4 T5
Sewers 75 % 20 % 4 % 1 %
Prison 25 % 50 % 20 % 5 %
Caves 0 % 40 % 50 % 10 %
City 0 % 20 % 40 % 40 %
Halls 0 % 0 % 20 % 80 %

Tier 1 items currently don't appear in the dungeon and are only part of player's starting equipment.

Heaps[]

Items randomly scattered in standard rooms have a 5 % chance to spawn inside skeletal remains, 25 % chance to spawn inside a chest (which has a 20 % chance to be a mimic if not on floor 1), and a 70 % chance to just be lying freely on the floor. Equipment pieces have (level + 1) * 25 % chance (or 50 % chance for artifact) to spawn inside a locked chest, which has a 10 % chance to be a golden mimic.

Level Feelings[]

Modifies Depth Feelings

Every floor has a 50% chance to generate with a level feeling. The level feelings (except for darkness feeling) alter floor generation.

Darkness[]

Darkness Floor
You can hear enemies moving in the darkness.

Encountering this depth feeling permanently increases enemy spawn rate and lowers the range of your field of view for a given floor. In addition, a single torch is spawned somewhere in the level, which will temporarily bring your field of view back to normal once lit. The torch can appear as a reward in special rooms, too.

Chasms[]

Chasm Floor
Your steps echo across the dungeon.

Makes the rooms appear as standalone pillars in a sea of chasms, connected with paths of decorative floor tiles. Increases the difficulty of fighting flying and ranged enemies, as there's less room to maneuver or hide, but with a Featherfall spell it can actually always grant an escape route.

Unlike in original PD, Chasm depths can spawn above boss floors. The Hero and all items dropped into chasms in this case will be placed in the starting room.

More water[]

Water Floor
You hear water splashing around you.

Generates more tiles with water. Having Moss Clump trinket in your inventory makes this level feeling more common.

More grass[]

Grass Floor
The smell of vegetation is thick in the air.

Generates more tiles with grass. However, grass on these floors is 50% less likely to drop dew when trampled. Having Moss Clump trinket in your inventory makes this level feeling more common.

Large floor[]

Large Floor
This dungeon floor seems unusually large.

Generates ~50% more standard rooms, 1 extra special room, 33% more enemies, 2 more random items, 1 more food item, and 1 more Torch if Into Darkness challenge is enabled.

More traps[]

Traps Floor
The ground seems especially treacherous here.

Generates four times more visible traps than usual. Number of hidden traps stays the same.

Many secrets[]

Secrets Floor
The atmosphere hints that this floor hides many secrets.

Chance for a door to be hidden on this floor is (0.5 + normalchance)/2. This makes doors more likely to be hidden in the early floors, but less likely to be hidden in later floors compared to normal floors. Every standard room still needs to have at least one door leading to it which isn't hidden. However, rooms are no longer required to have a "visible" connection to the entrance room leading to sections of the floor possibly being hidden.

Additionally, an extra secret room will generate on this floor (does not count to the number of secret rooms generated per chapter).

Advertisement