Binding of Isaac: Rebirth Wiki
Advertisement

Rules of map generation and Secret Room placement[]

Made by Uncausedruby2

The page doesn't list how the map is laid out before applying special rooms, rules for placing the Secret Room, and whether or not room layouts (and therefore possible doors in rooms) are decided before or after placing Secret Rooms. If the source code for this can be put here it would be greatly appreciated, but for now I'll add observations as I study maps.

Map Layout Observations[]

  • There will always be at least 2 rooms connected to the start room.
  • Maps will not generate in ways that create 2x2 boxes of rooms.
    • Double, quadruple, and L-shaped rooms count as a single room for this purpose, hence why it is common to see two regular rooms placed on the same side of a large room.
    • Rooms randomly placed on XL floors after initial map generation can ignore this rule.
  • Special rooms always generate in a certain order, and are placed based on distance from the start room. From the closest to the start room to the **furthest** (and barring loops and large rooms connected to more than one room on any given side), the order of Special Rooms encountered is:
    • Bedroom
    • Vault/Arcade (mutually exclusive)
    • Challenge/Boss Challenge Room (on odd/even floors, respectively)
    • Miniboss
    • Curse Room
    • Library
    • Dice/Sacrifice Room (mutually exclusive)
    • Treasure Room
    • Shop
    • Super Secret Room (replaces the end-room it occupies)
    • Boss Room
I'll just say here that the challenge/boss challenge on odd/even levels is a good catch, something easily glossed over but seems to hold true. --Frionil (talk) 14:53, 9 March 2020 (UTC)

Secret Room Observations[]

  • Secret Rooms will never border Boss Rooms or Super Secret Rooms, which are placed before the Secret Room is.
  • The following were not found to lock locations where the Secret Room spawns:
    • Proximity to the start room
    • The size of rooms
    • Whether or not the rooms bordering it are end-rooms or Special rooms (except Boss Rooms & Super Secret Rooms)
  • The number of rooms Secret Rooms border in order of most common to least common: 3, 4, 2, 1.
  • Secret Rooms most commonly border only 2 rooms if there are 0-1 other locations on the map where it would border 3+ rooms (viewing the map alone, room layouts were disregarded). Rules deciding when this occurs and where it's placed if it does occur are currently unknown.
    • Only exception found was a map on floor 1 with 3 locations having 3 bordering rooms.
  • There can be multiple favorable locations for the Secret Room to be on a floor; if that is the case, one of the locations is selected at random.

Inconsistencies in the explanation of level generation[]

by Elocutiona

I've been doing some testing, and my findings don't seem to match what the wiki says.

The distance function[]

First, I wanted to figure out how "distance from spawn room" is actually calculated. The realistic options were Euclidean distance, taxicab distance, Chebyshev distance, room count, and flood fill. With lots of screenshots, counting, and math in excel, I feel comfortable concluding that the game uses simple room count. In example 1, the boss room is clearly not the furthest room in terms of absolute distance, which means distance depends on the layout. It is only the furthest room in terms of room count (green). Big rooms only count as one room, or the super secret room would end up farther away from spawn than the boss room (red).

End room selection[]

What's stranger is the room highlighted in orange in example 1. By room count, this end room should've become the super secret room. Something similar can be seen with the curse room. It generated next to the spawn room when there were available end rooms further away. This leads me to the hypothesis that not all end rooms are considered when special rooms are placed. A possible explanation would be that once the number of special rooms is decided, that many end rooms are picked at random for sorting by distance, with the remaining end rooms not being considered, regardless of distance to spawn. It is possible that this random selection happens before or after the boss room has been placed, but it definitely happens before the super secret room and everything else is placed.

Special room order[]

Something is definitely also incorrect regarding the order of special room generation and placement. Either the list of priorities is incorrect, or the part about the game always placing them in the order of furthest to closest is wrong. In example 2, the dice room is by all metrics further from spawn than the treasure room. In example 3, the vault is also clearly further away from spawn than the challenge room, the curse room, the sacrifice room, and the treasure room.

There might be some insights in this alternate C# version. I'm not aware where to find an actual decompliation to try to decipher, only these pseudocode versions, but this one goes more into detail. From what I can try to guess based on this one, the room variant/shape chosen might affect the placement -- for the example of the closet curse room, it couldn't go anywhere closer due to its shape, and if there's no good location the game appears to retry the entire level instead of picking a different room variant... though take my interpretation with a grain of salt. Also please use external file hosts to upload non-content images, I won't delete these just yet but they will eventually be gone. --Frionil (talk) 17:13, 16 October 2023 (UTC)
That sounds plausible, though the same curse room weirdness can be seen in example 3 where all end rooms are the same size. It seemingly could've generated in the end room a bit further to the right, and the same goes for the boss challenge room. Perhaps I should gather some data from before the expansions where all normal end rooms were the same size. A possible explanation could be that room orientation matters and is determined before placement, but that would suggest that the game often generates many many layouts before even finding a valid candidate, and would lead to occasionally nonsensical end room ordering, which I personally have never observed. It actually WOULD explain the empty end room highlighted in orange in example 1, since the shop can't be further from spawn than the super secret room, and the super secret room could insist to have a door at the top or bottom rather than left or right. This would also explain the free end room in example 3 if the boss challenge room and the curse room insist on having a top or bottom entrance. The hole in this idea seems to be example 2, where free end rooms further from spawn with the same orientation exist for both the dice room and treasure room to occupy. --Elocutiona (talk) 05:51, 17 October 2023 (UTC)
Advertisement