Files
isaac-port/notes/systems/rules_floors.md
T
2026-10-26 11:20:16 -04:00

12 KiB

Rules research: floors (generation, special rooms, devil/angel deal, curses)

Repentance+ (v1.9.7.17) against the isaac-classic Flash engine (src/game/rooms/floor_generator.cpp, src/game/progression/devil_deal.cpp, resources/data/{stages,rooms,curses,items,itempools}.json and their repentance_plus/ layer). Stage numbers below are Rep's Level::_stage (1 Basement I .. 8 Womb II, 9 Blue Womb, 10 Sheol/Cathedral, 11 Dark Room/Chest, 12 Void, 13 Home). The engine's chapter is the same for 1..8, but its chapter 9 is Sheol (Rep 10) and 10 is the Chest (Rep 11). "alt" = stage types 4/5 (Downpour..Corpse): many checks count those one deeper (stage + 1). Curse bits: 1 Darkness, 2 Labyrinth, 4 Lost, 8 Unknown, 0x10 Cursed, 0x20 Maze, 0x40 Blind, 0x80 Giant. Achievements named from the game's achievements.xml.

room count, dead ends, retries (Level::generate_dungeon 0x740e10)

  • target = min(20, stage10/3 (int) + 5 + rand(0..1)). Flash/engine: min(20, 5 + 2.6chapter + rand(0..1)), rounded. Per chapter: Rep 8-9, 11-12, 15-16, 18-19, 20.. ; engine 8-9, 10-11, 13-14, 15-16, 18-19, 20..
  • alt stage with a mineshaft or mirror dimension: -3.
  • Labyrinth: min(45, int(target1.8)) (engine: min(30, target1.8)); else Lost: +4 (engine +4, capped 30).
  • challenge 21: 40 + rand%5; Void (12): 50 + rand%5.
  • hard mode (difficulty 1): +2 + rand(0..1). Engine: none.
  • Giant (0x80, never rolled): max(4, target*3/5).
  • dead ends required: 5 on stage 1, 6 otherwise; +1 Labyrinth; +2 Void; +1 Voodoo Head (599); +1 mineshaft/mirror. Engine: >= 4 (>= 3 on chapter 1).
  • LevelGenerator::Generate 0x9adbb0 places exactly target rooms (generate_rooms 0x9b04d0: a deque from the start room; the start branches into 2-3 (target < 16) or all candidates, any other room into min(candidates, coin+coin+coin+coin); a candidate cell touching >= 2 rooms is refused except on XL/Void at 1/10; a new room goes to the back of the queue 1/3, else the front). Short of dead ends: 5 tries of try_add_dead_end, then regenerate. Every 5th failure after the 10th, target + 1 (up to 64). After 100 failures it only logs. Engine: Flash's scan growth, accepts mapSize*1.25 >= target, 1000 attempts then fails.
  • Dead ends are sorted farthest from the start first (field +0x40, distance); GetNewEndRoom 0x9ae0e0 hands out the farthest one that fits the room's shape and doors. Engine: end_room() takes a random dead end.
  • Map 13x13 (169 cells), start (6,6). Engine 10 wide x 8 high (80 cells), start 35.
  • Room difficulty window (normal rooms): not XL and stage < 9: normal odd 1-5 / even 5-10, hard odd 5-10 / even 10-15; XL or stage >= 9: 1-10 (hard 5-15); fewer than 20 rooms in the window: 1-15. Each room 1 in 8 (generator RNG & 7 == 0) drops its minimum to 1 (place_special_rooms' normal-room loop). Engine: per-chapter room_difficulty is ported; XL uses the second chapter's even window; the 1-in-8 is missing.

special rooms, in order (Level::place_special_rooms 0x739370)

A challenge's roomset lists room types that are left out. "dead end" = GetNewEndRoom; a room that loses its roll gives the dead end back.

  1. Boss: BossPool::GetBossId; DetermineBossRoom 0x9aed50 = farthest dead end with distance > 1 that fits (XL: room for the second). XL: second boss room beside it from stage+1's pool. Void: 5 + rand(4) extra boss rooms from ids 0..69 minus a fixed list, fail with < 5. block_room_area(boss) blocks the cells around it.
  2. Super secret: 1, 2 with Luna (589). Any stage.
  3. Shop: stage < 7; or Silver Dollar (110) on 7-8; Wicked Crown (161) on 10 type 0, Holy Crown (155) 10 type 1. Subtype from Store Upgrade achievements 151-154 (+100 for Tainted Keeper 33). Engine: kept_rooms ported; but past chapter 6 Flash keeps the shop 1/25 (1/5 with Steam Sale): Rep never does.
  4. Treasure: same stage rule (Bloody Crown 111 for 7-8); 2 on XL. Subtype: 1% (or Golden Horse Shoe 82: seed % (100/mult) < 15, or special daily 19) "1" (3 with Pay to Win 112), else 2 with Pay to Win, else 0. Subtypes 1/3 rooms are not ported (rebirth_special_rooms has treasure 0 and pay_to_win 2 only).
  5. Mirror path only: an extra treasure room.
  6. Planetarium (Game::GetPlanetariumChance 0x74dbd0): float < chance and achievement 406. chance 0.01; 0 past stage 10, past 6 without Telescope Lens (152), past 8 without golden Lens or Mom's Box (439). No planetarium visited yet: 0.01 + 0.2*(effStage - 1 - treasureRoomsVisited) when treasure rooms visited < effStage-1 (+1.0 Crystal Ball 158), +0.15 Magic 8 Ball (194), +0.15 Crystal Ball, +0.069 Sausage (669), +0.15 Lens; visited: Lens +0.09, golden or Mom's Box +0.18, both +0.33. Clamp [0.01, 1]. Takes its own dead end, before the rooms below. Ported in repentance_plus room_placements (percent 1 + 20floors - 20entered.treasure - 1000*entered.planetarium).
  7. Stage < 11 only, steps 7-12:
    • Dice or sacrifice (one slot): seed%50==0, or seed%5==0 with player 0 keys >= 2 -> a dice room (unless excluded), else a sacrifice room. Placed (unless sacrifice excluded) if seed%7==0, else next&3==0 and (check_full_health or a Lazarus 8/11). So a dice room needs the sacrifice odds too.
    • Library: subtype rand(storeLevel+1); seed%20==0, else next&3==0 and game state flag 8 (a book picked up).
    • Curse room(s): 1, 2 with Voodoo Head (first subtype 1). NO roll: placed whenever not excluded and a dead end is left (asm 0x73b30b..0x73b38f: both branches place). Flash: 1/2, or 1/4 after a deal.
    • Miniboss: sin from those not met this run (game flags 9-14: wrath 2, gluttony 3, lust 1, sloth 0, envy 5, pride 6; super +7). Super: stage(+alt) > 2 and rand(N)==0, N = 80, 30 (achievement 4 The Womb), 10 (33 Everything is Terrible!!!), 5 (event counters 24+25 nonzero, unverified names). Ultra Pride (14): stage(+alt) >= 3, seed%10==0, once a run (flag 32). Room difficulty 1 (stage < 7) else 10, fallback 1-10. Placed 1/4, else (3/4 x) 1/3 on stage(+alt) 1. Engine odds match (1/4, 1/3 ch 1, Ultra Pride 1/10 ch > 2); its super-sin roll uses the curse odds from chapter 2.
    • Challenge: subtype 1 (boss challenge) when Level::_bossChallenge, set by Level::Init 0x744940 on stages 2,4,6,8 ALWAYS. Placed: full health, stage(+alt) >= 2, on stage 2 only 1/2. Engine: same placement, but boss challenge only 1/2 of even chapters, and Flash's hard-mode eternal challenge (alof) which Rep has not.
    • Arcade / chest: seed%10==0, or seed%3==0 with player 0 keys >= 2 -> chest (Cain's Birthright: arcade subtype 1 instead), else arcade. Arcade placed: (coins >= 5 or Cain BR) and stage(+alt) in {2,4,6,8} (Cain BR: any < 11). Chest placed: keys >= 2 and the same stage rule (no coin need). A chest roll with keys < 2 places nothing.
  8. Bedroom (stage < 7): Barren (19) if seed odd and Level::CanSpawnTrapDoor, else Isaac's (18). Placed 1/50, or 1/5 if any player has (red < 1 heart and no soul) or (no containers incl. bone and soul <= 1 heart). Ported.
  9. Mirror / mineshaft entrance / photo door rooms (alt_path.md).
  10. Secret rooms: 1 + Fragmented Card (102) + Luna. place_secret_room 0x9ae170: every empty, unblocked cell beside a room scores 10 + rand%5, -100 per neighbour room with no door slot toward it, -3 if < 3 neighbours and -3 more if < 2; best score wins, ties at random. Excluded (0x738d70, misnamed Console::Print): cells beside a boss, super secret or secret room, or beside a placed room's side without a door slot; on stage 11 the cells around the start. So a secret room may border a shop/treasure/curse room. Flash: never beside any dead end, boss, super secret or secret, columns 2-8 only.
  11. Stage 11 type 0 (Dark Room): one more dead-end room from the special set, variant 3 (3-9 after achievement 390).
  12. Ultra secret (type 29): every floor unless excluded, in a cell found by try_place_room beside rooms only through sides without door slots or beside boss/secret/super secret/curse rooms; Group 99. Reached only by Red Key.
  13. Normal rooms; start room special variant 2 (Chest/Dark Room their own).
  14. Greed takeover (flag 0x10 on the room): allowed unless both Greed and Super Greed met (game flags 15, 16). chance = (1.0, or 1.05 with player 0 coins >= 20, +0.1 once if flag 30, +0.02 once if flag 31,
    • 0.05*min(greed donations, 5)) / 3. Secret room: float < chance and stage > 4; then 999/1000 the shop is off. Shop: a second float < chance and stage > 3. Engine: secret 1/3 (ch > 4), shop 1/(6-min(ch,5)) (ch > 3), no miniboss room this floor, not the floor after Greed.
  15. Off-map: error room (every floor; engine: chapter < 9), black market, crawl space, boss rush, Mega Satan, Blue Womb / Home rooms, secret shop (Member Card), angel stairway, alt Mom (stage 7/8 alt).

devil and angel deal

Room::GetDevilRoomChance 0x7f92b0

0.01 base; Pentagram (51) 0.11 instead (+0.05 more with 2+); Black Candle (260) +0.15; Book of Belial (34, or its passive 59) +0.125; Book of Revelations (78) +0.175; beggar killed (level flag 1) +0.35; +0.35 unless in the last boss room after taking damage there (then Act of Contrition 601: +0.15); floor without red-heart damage (level flag 4 clear) +0.99, else Act of Contrition +0.4; shopkeeper killed this floor (level flag 0x40) +0.1; Number Magnet (174) +0.1/0.15/0.2; golden Rosary Bead +0.05/0.1; Sausage +0.069; +0.1 per room temporary effect of item 292 (Satanic Bible, Room+0x1218 list, unverified). Last deal stage (alt +1): same or next floor x0.25, two later x0.5. Disabled -> 0. Goat Head (215, held or effect) 66.6. Special daily 17 -> 1 until Krampus met. Eucharist (499) 1. Greed: 0 until wave 11 (Greedier 12), then 1.

Level::CanSpawnDevilRoom 0x749830

Not challenge 44, not pre-ascent, not the Ascent (stage 1-6 with game flag 48), not alt effective stage 8 (Corpse II; XL counts +1). Normal/hard: effective stage (XL +1, alt +1) 2..8; stage 1 only in special daily 17; stage 6 needs achievement 4 (The Womb). The last boss room's config must have >= 2 door slots. Greed: any stage.

Level::InitializeDevilAngelRoom 0x7499a0, get_angel_room_chance 0x7f96f0

Angel if float < angel chance (or forced). Angel chance: 1.0 when no devil room was visited yet (game flag 6), else 0.5; each of Key Piece 1 (238), Key Piece 2 (239), Book of Virtues (584): c += (1-c)*0.25; 10+ coins donated this floor: c += (1-c)*0.5; devil beggar killed (level flag 2): (1-c)*0.25; beggar left (8) xor devil beggar left (0x10): +(1-c)*0.1 / -(1-c)0.1. Then: if Level::_angelRoomChance > 0, or Book of Virtues, or (Act of Contrition and a devil room spawned) -> c += (1-c)_angelRoomChance; else if no devil room has spawned (game flag 5) or any devil deal was taken -> 0. Eucharist 1. Clamp [0,1]. Devil room: subtype 1 with Number Magnet; Womb II (effective 8) before It Lives (achievement 34): variant 100 only. Up to 10 draws until the room and the boss room share >= 2 door slots. Krampus (devil, achievement 142, not met this run, subtype 0): seed%20 < k, k = 0, 1 once a devil room was visited, 3 once a deal was taken (special daily 17: +10); sets flag 0x10 on the room and Krampus met (flag 29). Engine: angel = no deals and a deal door opened before, 1/2 (+angel_chance trait). Krampus 1/10, or 1/3 after deals.

prices (Room::GetShopItemPrice 0x8151e0)

Devil room / black market: -(items.xml devilprice) (default 1; 42 items 2). Soul hearts only without red containers (converted elsewhere). Item tag 0x200000000: -10 (one heart + one soul, unverified). Pound of Flesh, Keeper pricing (15/30 coins) and Your Soul are separate. Engine: 1 in 5 offers random soul price, else a heart price by its double_heart_price list (Flash's 11 items).

curse roll (Level::Init 0x744940)

N = 80 (hard 40); achievement 4 The Womb: 30 (hard 20); achievement 33 Everything is Terrible!!!: 10 (hard 6); event counter 11 > 0 or a daily: 5 (hard 3). No curse on stage 1 without achievement 33, on Home (13), on stages 1-6 of the Ascent, with Black Candle (260), special daily 18. rand(N)==0, then next % 6: 0 Labyrinth (only CanStageHaveCurseOfLabyrinth 0x7385c0: odd stage < 8, not Greed, not challenge 44), 1 Lost (not Greed, not challenge 44), 2 Darkness, 3 Unknown, 4 Maze (not Greed), 5 Blind (not a daily); a refused pick is no curse. Never Cursed or Giant. Then MC_POST_CURSE_EVAL (0x864ae0), challenge curses added and its prevented ones removed (Labyrinth only where allowed), special daily 37 adds 0x4c. Blue Womb (9) or victory lap > 2: Darkness removed. Engine: odds 80/60/25/15 by Flash lockers, rolled per curse in order (Labyrinth 1/N, Lost and Darkness 1/2N), any chapter, the Rep-only curses odds_scale 0.