Zamiel

Average Floor Science

Sep 6th, 2021 (edited)
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.66 KB | None | 0 0
  1. I wrote a mod to count the number of rooms on a floor, and then restart the game, and continue doing that for 10,000 iterations. This allows us to see the average number of rooms per floor and if the different kinds of stages have any effect.
  2.  
  3. Results:
  4. - The average number of rooms on floor 1 is 9.5. The stage type makes no difference.
  5. - The average number of rooms on Basement 2, Cellar 2, and Burning Basement 2 is 12.6.
  6. - The average number of rooms on Downpour 2 and Dross 2 is 12.7. This is probably due to the floor generation algorithm having to place the mirror room.
  7. - The average number of rooms on floor 3 is 15.7. The stage type makes no difference.
  8.  
  9. Conclusions:
  10. - On Basement 1 / Cellar 1 / Burning Basement 1, you might want to spend an extra key to go to Downpour 1 / Dross 1. In return, the floor will have 3 less rooms on average, but the enemies will be harder to dodge and the boss will be harder.
  11. - On Basement 2 / Cellar 2 / Burning Basement 2, you probably will want to spend an key to go to Downpour 2 / Dross 2. In return, the floor will have 3 less rooms on average, but the enemies will be harder to dodge and the boss will be harder (on average).
  12. - Another factor to consider is that the alt paths have two items in the Treasure Room, but this is most irrelevant as:
  13. - 1) You may not find the Treasure Room while on the way to the boss.
  14. - 2) You may not have a key to open the Treasure Room (especially since you just used one to enter the alt floor).
  15. - 3) The average expected value of the Treasure Room is extremely low.
  16.  
  17.  
  18.  
  19.  
  20.  
  21. Full data is below.
  22.  
  23. Floor 1 - Basement 1:
  24. Total floors: 10000
  25. Total rooms: 95094
  26. Average: 9.51
  27. Room count of 8: 1547 (15.47%)
  28. Room count of 9: 4111 (41.11%)
  29. Room count of 10: 2602 (26.02%)
  30. Room count of 11: 1236 (12.36%)
  31. Room count of 12: 450 (4.5%)
  32. Room count of 13: 53 (0.53%)
  33. Room count of 14: 1 (0.01%)
  34.  
  35. Floor 1 - Cellar 1:
  36. Total floors: 10000
  37. Total rooms: 95050
  38. Average: 9.51
  39. Room count of 8: 1490 (14.9%)
  40. Room count of 9: 4180 (41.8%)
  41. Room count of 10: 2628 (26.28%)
  42. Room count of 11: 1256 (12.56%)
  43. Room count of 12: 384 (3.84%)
  44. Room count of 13: 62 (0.62%)
  45.  
  46. Floor 1 - Burning Basement 1:
  47. Total floors: 10000
  48. Total rooms: 95054
  49. Average: 9.51
  50. Room count of 8: 1474 (14.74%)
  51. Room count of 9: 4182 (41.82%)
  52. Room count of 10: 2660 (26.6%)
  53. Room count of 11: 1244 (12.44%)
  54. Room count of 12: 380 (3.8%)
  55. Room count of 13: 60 (0.6%)
  56.  
  57. Floor 1 - Downpour 1:
  58. Total floors: 10000
  59. Total rooms: 94928
  60. Average: 9.49
  61. Room count of 8: 1534 (15.34%)
  62. Room count of 9: 4126 (41.26%)
  63. Room count of 10: 2709 (27.09%)
  64. Room count of 11: 1192 (11.92%)
  65. Room count of 12: 388 (3.88%)
  66. Room count of 13: 50 (0.5%)
  67. Room count of 14: 1 (0.01%)
  68.  
  69. Floor 1 - Dross 1:
  70. Total floors: 10000
  71. Total rooms: 95050
  72. Average: 9.51
  73. Room count of 8: 1494 (14.94%)
  74. Room count of 9: 4131 (41.31%)
  75. Room count of 10: 2711 (27.11%)
  76. Room count of 11: 1228 (12.28%)
  77. Room count of 12: 368 (3.68%)
  78. Room count of 13: 67 (0.67%)
  79. Room count of 14: 1 (0.01%)
  80.  
  81. Floor 2 - Basement 2:
  82. Total floors: 10000
  83. Total rooms: 126118
  84. Average: 12.61
  85. Room count of 11: 1680 (16.8%)
  86. Room count of 12: 3746 (37.46%)
  87. Room count of 13: 2332 (23.32%)
  88. Room count of 14: 1464 (14.64%)
  89. Room count of 15: 599 (5.99%)
  90. Room count of 16: 154 (1.54%)
  91. Room count of 17: 25 (0.25%)
  92.  
  93. Floor 2 - Cellar 2:
  94. Total floors: 10000
  95. Total rooms: 125983
  96. Average: 12.6
  97. Room count of 11: 1643 (16.43%)
  98. Room count of 12: 3799 (37.99%)
  99. Room count of 13: 2432 (24.32%)
  100. Room count of 14: 1366 (13.66%)
  101. Room count of 15: 593 (5.93%)
  102. Room count of 16: 152 (1.52%)
  103. Room count of 17: 15 (0.15%)
  104.  
  105. Floor 2 - Burning Basement 2:
  106. Total floors: 10000
  107. Total rooms: 126076
  108. Average: 12.61
  109. Room count of 11: 1629 (16.29%)
  110. Room count of 12: 3781 (37.81%)
  111. Room count of 13: 2443 (24.43%)
  112. Room count of 14: 1361 (13.61%)
  113. Room count of 15: 619 (6.19%)
  114. Room count of 16: 152 (1.52%)
  115. Room count of 17: 15 (0.15%)
  116.  
  117. Floor 2 - Downpour 2:
  118. Total floors: 10000
  119. Total rooms: 127085
  120. Average: 12.71
  121. Room count of 9: 2 (0.02%)
  122. Room count of 10: 142 (1.42%)
  123. Room count of 11: 1019 (10.19%)
  124. Room count of 12: 2574 (25.74%)
  125. Room count of 13: 4195 (41.95%)
  126. Room count of 14: 2008 (20.08%)
  127. Room count of 15: 57 (0.57%)
  128. Room count of 16: 3 (0.03%)
  129.  
  130. Floor 2 - Dross 2:
  131. Total floors: 10000
  132. Total rooms: 127116
  133. Average: 12.71
  134. Room count of 9: 2 (0.02%)
  135. Room count of 10: 144 (1.44%)
  136. Room count of 11: 1009 (10.09%)
  137. Room count of 12: 2545 (25.45%)
  138. Room count of 13: 4249 (42.49%)
  139. Room count of 14: 1985 (19.85%)
  140. Room count of 15: 64 (0.64%)
  141. Room count of 16: 2 (0.02%)
  142.  
  143. Floor 3 - Caves 1:
  144. Total floors: 10000
  145. Total rooms: 156895
  146. Average: 15.69
  147. Room count of 15: 4093 (40.93%)
  148. Room count of 16: 5246 (52.46%)
  149. Room count of 17: 415 (4.15%)
  150. Room count of 18: 188 (1.88%)
  151. Room count of 19: 37 (0.37%)
  152. Room count of 20: 19 (0.19%)
  153. Room count of 21: 2 (0.02%)
  154.  
  155. Floor 3 - Catacombs 1:
  156. Total floors: 10000
  157. Total rooms: 156851
  158. Average: 15.69
  159. Room count of 15: 4083 (40.83%)
  160. Room count of 16: 5291 (52.91%)
  161. Room count of 17: 385 (3.85%)
  162. Room count of 18: 182 (1.82%)
  163. Room count of 19: 52 (0.52%)
  164. Room count of 20: 6 (0.06%)
  165. Room count of 21: 1 (0.01%)
  166.  
  167. Floor 3 - Flooded Caves 1:
  168. Total floors: 10000
  169. Total rooms: 156836
  170. Average: 15.68
  171. Room count of 15: 4102 (41.02%)
  172. Room count of 16: 5280 (52.8%)
  173. Room count of 17: 377 (3.77%)
  174. Room count of 18: 178 (1.78%)
  175. Room count of 19: 49 (0.49%)
  176. Room count of 20: 12 (0.12%)
  177. Room count of 21: 2 (0.02%)
  178.  
  179. Floor 3 - Mines 1:
  180. Total floors: 10000
  181. Total rooms: 156869
  182. Average: 15.69
  183. Room count of 15: 4047 (40.47%)
  184. Room count of 16: 5328 (53.28%)
  185. Room count of 17: 404 (4.04%)
  186. Room count of 18: 160 (1.6%)
  187. Room count of 19: 52 (0.52%)
  188. Room count of 20: 9 (0.09%)
  189.  
  190. Floor 3 - Ashpit 1:
  191. Total floors: 10000
  192. Total rooms: 156806
  193. Average: 15.68
  194. Room count of 15: 4046 (40.46%)
  195. Room count of 16: 5368 (53.68%)
  196. Room count of 17: 390 (3.9%)
  197. Room count of 18: 137 (1.37%)
  198. Room count of 19: 48 (0.48%)
  199. Room count of 20: 11 (0.11%)
  200.  
  201.  
  202.  
  203.  
  204. Floor 3 - Caves 1 (Hard Mode):
  205. Total floors: 10000
  206. Total rooms: 180384
  207. Average: 18.04
  208. Room count of 17: 2353 (23.53%)
  209. Room count of 18: 5021 (50.21%)
  210. Room count of 19: 2546 (25.46%)
  211. Room count of 20: 57 (0.57%)
  212. Room count of 21: 16 (0.16%)
  213. Room count of 22: 6 (0.06%)
  214. Room count of 23: 1 (0.01%)
  215.  
  216.  
  217.  
  218.  
  219. Here's a copy of the mod used:
  220.  
  221.  
  222.  
  223.  
  224. -- Constants
  225. local MOD_NAME = "floor-average-finder"
  226. --local WARP_COMMAND = "stage 2b"
  227. local STAGE = 1
  228. local STAGE_TYPE = 0
  229. local MAX_ROOM_INDEX = 168
  230.  
  231. local mod = RegisterMod(MOD_NAME, 1)
  232. local game = Game()
  233. local sfx = SFXManager()
  234. local totalFloors = 0
  235. local totalRooms = 0
  236. local roomMap = {}
  237.  
  238. local isEnabled = true
  239.  
  240. -- From: http://lua-users.org/wiki/SimpleRound
  241. local function round(num, numDecimalPlaces)
  242. return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
  243. end
  244.  
  245. -- From: https://stackoverflow.com/questions/33510736
  246. local function hasValue(t, val)
  247. for index, value in ipairs(t) do
  248. if value == val then
  249. return true
  250. end
  251. end
  252.  
  253. return false
  254. end
  255.  
  256. function mod:postRender(player)
  257. if isEnabled then
  258. Isaac.ExecuteCommand("restart")
  259. end
  260. end
  261.  
  262. function mod:postNewLevel(player)
  263. local level = game:GetLevel()
  264. local stage = level:GetStage()
  265. local stageType = level:GetStageType()
  266.  
  267. if stage ~= STAGE or stageType ~= STAGE_TYPE then
  268. return
  269. end
  270.  
  271. totalFloors = totalFloors + 1
  272.  
  273. -- getNumRooms
  274. local roomSafeIndexes = {}
  275. for i = 0, MAX_ROOM_INDEX do
  276. local room = level:GetRoomByIdx(i)
  277. if room ~= nil then
  278. local data = room.Data
  279. if data ~= nil then
  280. if (
  281. data.Type ~= RoomType.ROOM_SECRET
  282. and data.Type ~= RoomType.ROOM_SUPERSECRET
  283. and data.Type ~= RoomType.ROOM_ULTRASECRET
  284. and not hasValue(roomSafeIndexes, room.SafeGridIndex)
  285. ) then
  286. roomSafeIndexes[#roomSafeIndexes + 1] = room.SafeGridIndex
  287. end
  288. end
  289. end
  290. end
  291. local numRooms = #roomSafeIndexes
  292.  
  293. totalRooms = totalRooms + numRooms
  294. if roomMap[numRooms] == nil then
  295. roomMap[numRooms] = 0
  296. end
  297. roomMap[numRooms] = roomMap[numRooms] + 1
  298.  
  299. Isaac.DebugString("Total floors: " .. tostring(totalFloors))
  300. Isaac.DebugString("Total rooms: " .. tostring(totalRooms))
  301. local average = round(totalRooms / totalFloors, 2)
  302. Isaac.DebugString("Average: " .. tostring(average))
  303.  
  304. local sortedKeys = {}
  305. for k, v in pairs(roomMap) do
  306. sortedKeys[#sortedKeys + 1] = k
  307. end
  308. table.sort(sortedKeys)
  309. for _, sortedKey in ipairs(sortedKeys) do
  310. local roomCount = roomMap[sortedKey]
  311. local averagePercent = round((roomCount / totalFloors) * 100, 2)
  312. Isaac.DebugString(
  313. "Room count of " .. tostring(sortedKey) .. ": " .. tostring(roomCount)
  314. .. " (" .. averagePercent .. "%)"
  315. )
  316. end
  317.  
  318. if totalFloors >= 10000 then
  319. isEnabled = false
  320. sfx:Play(SoundEffect.SOUND_ANGEL_BEAM)
  321. end
  322. end
  323.  
  324. function mod:postGameStarted()
  325. local seeds = game:GetSeeds()
  326. if seeds:HasSeedEffect(SeedEffect.SEED_PREVENT_ALL_CURSES) then
  327. --Isaac.ExecuteCommand(WARP_COMMAND)
  328. else
  329. Isaac.DebugString("ERROR: Turn on BLCK CNDL Easter Egg.")
  330. end
  331. end
  332.  
  333. mod:AddCallback(ModCallbacks.MC_POST_RENDER, mod.postRender)
  334. mod:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, mod.postNewLevel)
  335. mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.postGameStarted)
  336.  
  337. Isaac.DebugString(MOD_NAME .. " initialized.")
  338.  
Advertisement
Add Comment
Please, Sign In to add comment