Advertisement
imbued

SRM Solver 15

Dec 30th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 328.47 KB | None | 0 0
  1. from copy import copy
  2. import itertools
  3. import numpy as np
  4.  
  5. """
  6.  
  7. - This script does NOT handle spawners (except for rupee clusters)
  8. - This script does NOT handle scarecrow memory leak
  9.  
  10. - This script does not account for ISoT memory leak for solution options
  11.  
  12.  
  13. FOR DEKU PALACE, THIS DOES NOT ACCOUNT FOR POTENTIALLY NEEDING TO BREAK A POT FOR THE SUPERSLIDE
  14.  
  15. THIS SCRIPT DOES NOT ACCOUNT FOR GOLD SKULLTULA TOKENS
  16.  
  17.  
  18. """
  19.  
  20.  
  21.  
  22. """
  23.  
  24. Note: Node size is 0x10 = 16 on English and 0x30 = 48 on JP
  25.  
  26. """
  27.  
  28. version = 'English'
  29.  
  30. if version == 'English':
  31. node_size = 0x10
  32. elif version == 'JP':
  33. nodesize = 0x30
  34. else:
  35. print('Error: Invalid Version (choose "English" or "JP" )')
  36.  
  37.  
  38.  
  39. class Actor:
  40.  
  41. """
  42.  
  43. name: name of the actor, some string
  44.  
  45. Id: Actor id, string of 4 integers
  46.  
  47. size: the size of an actor instance for this actor (number of bytes, in decimal)
  48.  
  49. category: the actor category (category 5 is treated differently than others)
  50. For now, giving everything not category 5 a category of 0
  51.  
  52. overlay_type: determines where the AF loads in the heap
  53.  
  54. unloadable: a boolean for whether or not it is possible to deallocate this actor without changing rooms
  55.  
  56. address: the memory address of the actor in decimal (can convert to a hex string for output)
  57. Note: The earliest address we handle is 0x40B150 = 4239696. All addresses must be multiples of 16
  58.  
  59. room_number: the number of the room these actors are associated with; if the actor is a transition (i..e Plane
  60. or Door), then set room_numer = False
  61.  
  62.  
  63. priority: an index to differentiate copies of the same instance
  64.  
  65. from_spawner: True or False (True if it is from a spawner, like rupees from a cluster; False otherwise)
  66.  
  67. transition: False is the actor is not a Loading Plane or a Door. Otherwise, it is a list of the rooms that the transition actor connects, ordered from least to greatest room number
  68.  
  69. clearable: True if it is possible to set a flag to make this actor not respawn upon reloading the room (though, unless it it Category 5, it will attempt to reload and then immediately deallocate), False otherwise
  70.  
  71. cleared: True if the flag was set to clear this actor, False otherwise
  72.  
  73. """
  74.  
  75. def __init__(self, name, Id, size, category, overlay_type, unloadable, address, room_number, priority, from_spawner, transition, clearable, cleared):
  76. self.name = name
  77. self.Id = Id
  78. self.size = size
  79. self.category = category
  80. self.overlay_type = overlay_type
  81. self.unloadable = unloadable
  82. self.address = address
  83. self.room_number = room_number
  84. self.priority = priority
  85. self.from_spawner = from_spawner
  86. self.transition = transition
  87. self.clearable = clearable
  88. self.cleared = cleared
  89.  
  90. class Room:
  91.  
  92. """
  93.  
  94. number: the room number (i.e. Room 0 has number 0)
  95.  
  96. priority_queue: this will be the list of actor instances of the room, in order
  97.  
  98. clock_exists: boolean for whether or not the clock is an actor in the queue
  99.  
  100. clock_priority: if clock_exists == False, then clock_priority will be a number
  101. to determine where in the queue the clock should be loaded, for
  102. example, if clock_priority is 2, then it means that the clock
  103. should be the 3rd actor to appear in the queue (first index is 0)
  104.  
  105. """
  106.  
  107. def __init__(self, number, priority_queue, clock_exists, clock_priority):
  108. self.number = number
  109. self.priority_queue = priority_queue
  110. self.clock_exists = clock_exists
  111. self.clock_priority = clock_priority
  112.  
  113. class Node:
  114.  
  115. """
  116. address: which address in memory the node is at (as a base-10 integer for now)
  117.  
  118. size: nodes should be 16 bytes (english), so input 16
  119.  
  120. """
  121.  
  122. def __init__(self, address, size):
  123. self.address = address
  124. self.size = size
  125.  
  126. class Overlay:
  127.  
  128. def __init__(self, address, Id, size):
  129. self.address = address
  130. self.Id = Id
  131. self.size = size
  132.  
  133.  
  134. """
  135.  
  136. We define the Clock actor ahead of time as it is not necessarily present in each room
  137.  
  138. """
  139.  
  140.  
  141. Clock = Actor(name='Clock', Id='015A', size=340, category=0, overlay_type='A', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  142.  
  143. ###############################################################################
  144.  
  145. Palace_Room0_queue = [
  146. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[0,1], clearable=False, cleared=False),
  147. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=1, from_spawner=False, transition=[0,2], clearable=False, cleared=False),
  148. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=2, from_spawner=False, transition=[0,1], clearable=False, cleared=False),
  149. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=3, from_spawner=False, transition=[0,2], clearable=False, cleared=False),
  150. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=4, from_spawner=False, transition=[0,1], clearable=False, cleared=False),
  151. Actor(name='???02AE ', Id='02AE', size=0x14C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  152. Actor(name='Deku Scrub Guard (Palace Entrance)', Id='01A0', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  153. Actor(name='Deku Scrub Guard (Palace Entrance)', Id='01A0', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  154. Actor(name='Poisoned/Purified Water Elements', Id='0186', size=0x170, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  155. Actor(name='Poisoned/Purified Water Elements', Id='0186', size=0x170, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  156. Actor(name='Poisoned/Purified Water Elements', Id='0186', size=0x170, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  157. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  158. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  159. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  160. Actor(name='Mushroom Scent Cloud', Id='023B', size=0x144, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  161. Actor(name='Wilted Deku Baba & Mini Baba', Id='0066', size=0x2C8, category=5, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  162. Actor(name='Monkey', Id='019E', size=0x3EC, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  163. Actor(name='Big Octo', Id='01A8', size=0x3F8, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  164. Actor(name='Square Sign', Id='00A8', size=0x1F0, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  165. Actor(name='Square Sign', Id='00A8', size=0x1F0, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  166. Actor(name='Square Sign', Id='00A8', size=0x1F0, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  167. Actor(name='Magic Bean Plant', Id='0091', size=0x204, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  168. Actor(name='Magic Bean Plant', Id='0091', size=0x204, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  169. Actor(name='Clock', Id='015A', size=340, category=0, overlay_type='A', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  170. Actor(name='Bombable Rock', Id='0092', size=0x208, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  171. Actor(name='Bombable Rock', Id='0092', size=0x208, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  172. Actor(name='Directional Sign', Id='0026', size=0x194, category=0, overlay_type='B', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  173. Actor(name='Directional Sign', Id='0026', size=0x194, category=0, overlay_type='B', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  174. Actor(name='Directional Sign', Id='0026', size=0x194, category=0, overlay_type='B', unloadable=False, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  175. Actor(name='Directional Sign', Id='0026', size=0x194, category=0, overlay_type='B', unloadable=False, address=0, room_number=0, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  176. Actor(name='???017C', Id='017C', size=0x164, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  177. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  178. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  179. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  180. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  181. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=4, from_spawner=False, transition=False, clearable=False, cleared=False),
  182. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=5, from_spawner=False, transition=False, clearable=False, cleared=False),
  183. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=6, from_spawner=False, transition=False, clearable=False, cleared=False),
  184. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=7, from_spawner=False, transition=False, clearable=False, cleared=False),
  185. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=8, from_spawner=False, transition=False, clearable=False, cleared=False),
  186. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=9, from_spawner=False, transition=False, clearable=False, cleared=False),
  187. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=10, from_spawner=False, transition=False, clearable=False, cleared=False),
  188. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=11, from_spawner=False, transition=False, clearable=False, cleared=False),
  189. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=12, from_spawner=False, transition=False, clearable=False, cleared=False),
  190. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=13, from_spawner=False, transition=False, clearable=False, cleared=False),
  191. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=14, from_spawner=False, transition=False, clearable=False, cleared=False),
  192. Actor(name='Lilypad', Id='01B9', size=0x16C, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=15, from_spawner=False, transition=False, clearable=False, cleared=False),
  193. ]
  194.  
  195.  
  196. Palace_Room1_queue = [
  197. Palace_Room0_queue[0],
  198. Palace_Room0_queue[2],
  199. Palace_Room0_queue[4],
  200. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  201. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=True, cleared=False),
  202. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=True, cleared=False),
  203. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=3, from_spawner=False, transition=False, clearable=True, cleared=False),
  204. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=4, from_spawner=False, transition=False, clearable=True, cleared=False),
  205. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=1, priority=5, from_spawner=False, transition=False, clearable=True, cleared=False),
  206. Actor(name='Grotto Hole', Id='0055', size=0x194, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  207. Actor(name='Poisoned/Purified Water Elements', Id='0186', size=0x170, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  208. Actor(name='Elevator (Deku Palace & Woodfall Temple)', Id='013C', size=0x18C, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  209. Actor(name='Elevator (Deku Palace & Woodfall Temple)', Id='013C', size=0x18C, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  210. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  211. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  212. Actor(name='Bronze Boulder', Id='00FC', size=0x1A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  213. Actor(name='Bronze Boulder', Id='00FC', size=0x1A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  214. Actor(name='Bronze Boulder', Id='00FC', size=0x1A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  215. Actor(name='Pot', Id='0082', size=0x19C, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  216. Actor(name='Pot', Id='0082', size=0x19C, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  217. Actor(name='Rupee Cluster', Id='00E8', size=360, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  218. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  219. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  220. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  221. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  222. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=4, from_spawner=False, transition=False, clearable=False, cleared=False),
  223. Actor(name='Mad Scrub (Field Enemy)', Id='003B', size=0x2C8, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  224. Actor(name='Mad Scrub (Field Enemy)', Id='003B', size=0x2C8, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  225. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  226. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  227. Actor(name='Clock', Id='015A', size=340, category=0, overlay_type='A', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  228. Actor(name='???017C', Id='017C', size=0x164, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  229. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  230. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  231. ]
  232.  
  233.  
  234. Palace_Room2_queue = [
  235. Palace_Room0_queue[1],
  236. Palace_Room0_queue[3],
  237. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  238. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=1, from_spawner=False, transition=False, clearable=True, cleared=False),
  239. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=2, from_spawner=False, transition=False, clearable=True, cleared=False),
  240. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=3, from_spawner=False, transition=False, clearable=True, cleared=False),
  241. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=4, from_spawner=False, transition=False, clearable=True, cleared=False),
  242. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=5, from_spawner=False, transition=False, clearable=True, cleared=False),
  243. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=6, from_spawner=False, transition=False, clearable=True, cleared=False),
  244. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=7, from_spawner=False, transition=False, clearable=True, cleared=False),
  245. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=8, from_spawner=False, transition=False, clearable=True, cleared=False),
  246. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=9, from_spawner=False, transition=False, clearable=True, cleared=False),
  247. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=10, from_spawner=False, transition=False, clearable=True, cleared=False),
  248. Actor(name='Collectible (Rupee)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=11, from_spawner=False, transition=False, clearable=True, cleared=False),
  249. Actor(name='Poisoned/Purified Water Elements', Id='0186', size=0x170, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  250. Actor(name='Elevator (Deku Palace & Woodfall Temple)', Id='013C', size=0x18C, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  251. Actor(name='Elevator (Deku Palace & Woodfall Temple)', Id='013C', size=0x18C, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  252. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  253. Actor(name='Collectible (Heart Piece)', Id='000E', size=0x1A8, category=0, overlay_type='B', unloadable=True, address=0, room_number=2, priority=12, from_spawner=False, transition=False, clearable=True, cleared=False),
  254. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  255. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  256. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  257. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  258. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=4, from_spawner=False, transition=False, clearable=False, cleared=False),
  259. Actor(name='Deku Scrub Guard (Palace Gardens)', Id='017A', size=0x290, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=5, from_spawner=False, transition=False, clearable=False, cleared=False),
  260. Actor(name='Mad Scrub (Field Enemy)', Id='003B', size=0x2C8, category=5, overlay_type='A', unloadable=True, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  261. Actor(name='Mad Scrub (Field Enemy)', Id='003B', size=0x2C8, category=5, overlay_type='A', unloadable=True, address=0, room_number=2, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  262. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  263. Actor(name='Clock', Id='015A', size=340, category=0, overlay_type='A', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  264. Actor(name='???017C', Id='017C', size=0x164, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  265. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  266. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  267. Actor(name='Torch Stand (Generic)', Id='0039', size=0x1F4, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  268. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  269. Actor(name='Deku Flower', Id='0183', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=2, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  270. ]
  271.  
  272. ###############################################################################
  273.  
  274. Oceanside_Room3_queue = [
  275. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[3,4], clearable=False, cleared=False),
  276. Actor(name='Wooden Door', Id='0005', size=0x1CC, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[2,3], clearable=False, cleared=False),
  277. Actor(name='Stalchild (Oceanside Spider House)', Id='02A5', size=0x3EC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  278. Actor(name='Stalchild (Oceanside Spider House)', Id='02A5', size=0x3EC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  279. Actor(name='Stalchild (Oceanside Spider House)', Id='02A5', size=0x3EC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  280. Actor(name='Stalchild (Oceanside Spider House)', Id='02A5', size=0x3EC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  281. Actor(name='Pot', Id='0082', size=0x19C, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  282. Actor(name='Pot', Id='0082', size=0x19C, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  283. Actor(name='Oceanside Spider House Skull Kid Painting', Id='0210', size=0x244, category=0, overlay_type='A', unloadable=False, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  284. Actor(name='Oceanside Spider House Skull Kid Painting', Id='0210', size=0x244, category=0, overlay_type='A', unloadable=False, address=0, room_number=3, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  285. Actor(name='Oceanside Spider House Skull Kid Painting', Id='0210', size=0x244, category=0, overlay_type='A', unloadable=False, address=0, room_number=3, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  286. Actor(name='Oceanside Spider House Skull Kid Painting', Id='0210', size=0x244, category=0, overlay_type='A', unloadable=False, address=0, room_number=3, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False),
  287. Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  288. Actor(name='Spiderweb', Id='0125', size=0x2FC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  289. Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=1, from_spawner=False, transition=False, clearable=True, cleared=False),
  290. Actor(name='Bonk Actor (01E7)', Id='01E7', size=0x148, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  291. Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=2, from_spawner=False, transition=False, clearable=True, cleared=False),
  292. Actor(name='Bonk Actor (01E7)', Id='01E7', size=0x148, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  293. Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=3, from_spawner=False, transition=False, clearable=True, cleared=False),
  294. Actor(name='Bonk Actor (01E7)', Id='01E7', size=0x148, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  295. Actor(name='Tent-Shaped Spider Web', Id='01F4', size=0x3CC, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  296. Actor(name='Oceanside Spider House Fireplace Grate', Id='020F', size=0x284, category=0, overlay_type='A', unloadable=False, address=0, room_number=3, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  297. Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=4, from_spawner=False, transition=False, clearable=True, cleared=False),
  298. Actor(name='Bonk Actor (01E7)', Id='01E7', size=0x148, category=0, overlay_type='A', unloadable=True, address=0, room_number=3, priority=3, from_spawner=False, transition=False, clearable=False, cleared=False)
  299. ]
  300.  
  301.  
  302. Oceanside_Room4_queue = [
  303. Oceanside_Room3_queue[0],
  304. Actor(name='Skulltula', Id='0024', size=0x550, category=5, overlay_type='A', unloadable=True, address=0, room_number=4, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  305. Actor(name='Chest', Id='0006', size=548, category=0, overlay_type='A', unloadable=False, address=0, room_number=4, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  306. ]
  307.  
  308.  
  309.  
  310.  
  311.  
  312. ###############################################################################
  313.  
  314. Room0_queue = [
  315. Actor(name='Wooden Door', Id='0005', size=460, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[0,3], clearable=False, cleared=False),
  316. Actor(name='Loading Plane', Id='0018', size=332, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[0,1], clearable=False, cleared=False),
  317. Actor(name='Rupee Cluster', Id='00E8', size=360, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  318. Actor(name='Dripping Water Effect', Id='0170', size=3644, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  319. Actor(name='Dripping Water Effect', Id='0170', size=3644, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  320. Actor(name='Torch Stand (Generic)', Id='0039', size=500, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  321. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  322. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  323. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=0, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  324. Actor(name='???0158', Id='0158', size=328, category=0, overlay_type='A', unloadable=False, address=0, room_number=0, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  325. ]
  326.  
  327.  
  328. Room1_queue = [
  329. Actor(name='Door Shutter', Id='001E', size=360, category=0, overlay_type='B', unloadable=False, address=0, room_number=False, priority=0, from_spawner=False, transition=[1,2], clearable=False, cleared=False),
  330. Room0_queue[1],
  331. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=True, cleared=False),
  332. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=True, cleared=False),
  333. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=True, cleared=False),
  334. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=3, from_spawner=False, transition=False, clearable=True, cleared=False),
  335. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=4, from_spawner=False, transition=False, clearable=True, cleared=False),
  336. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=5, from_spawner=False, transition=False, clearable=True, cleared=False),
  337. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=6, from_spawner=False, transition=False, clearable=True, cleared=False),
  338. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=7, from_spawner=False, transition=False, clearable=True, cleared=False),
  339. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=8, from_spawner=False, transition=False, clearable=True, cleared=False),
  340. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=9, from_spawner=False, transition=False, clearable=True, cleared=False),
  341. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=10, from_spawner=False, transition=False, clearable=True, cleared=False),
  342. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=11, from_spawner=False, transition=False, clearable=True, cleared=False),
  343. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=12, from_spawner=False, transition=False, clearable=True, cleared=False),
  344. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=13, from_spawner=False, transition=False, clearable=True, cleared=False),
  345. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=14, from_spawner=False, transition=False, clearable=True, cleared=False),
  346. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=15, from_spawner=False, transition=False, clearable=True, cleared=False),
  347. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=16, from_spawner=False, transition=False, clearable=True, cleared=False),
  348. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=17, from_spawner=False, transition=False, clearable=True, cleared=False),
  349. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=18, from_spawner=False, transition=False, clearable=True, cleared=False),
  350. Actor(name='Bad Bat', Id='015B', size=476, category=5, overlay_type='A', unloadable=True, address=0, room_number=1, priority=19, from_spawner=False, transition=False, clearable=True, cleared=False),
  351. Actor(name='Torch Stand (Generic)', Id='0039', size=500, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  352. Actor(name='Torch Stand (Generic)', Id='0039', size=500, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  353. Actor(name='Torch Stand (Generic)', Id='0039', size=500, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  354. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False),
  355. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=1, from_spawner=False, transition=False, clearable=False, cleared=False),
  356. Actor(name='Pot', Id='0082', size=412, category=0, overlay_type='A', unloadable=True, address=0, room_number=1, priority=2, from_spawner=False, transition=False, clearable=False, cleared=False),
  357. Actor(name='Chest', Id='0006', size=548, category=0, overlay_type='A', unloadable=False, address=0, room_number=1, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  358. ]
  359.  
  360. ###############################################################################
  361.  
  362. Room0 = Room(0, Room0_queue, False, 2)
  363. Room1 = Room(1, Room1_queue, False, 2)
  364.  
  365.  
  366. Oceanside_Room3 = Room(3, Oceanside_Room3_queue, False, 2)
  367. Oceanside_Room4 = Room(4, Oceanside_Room4_queue, False, 1)
  368.  
  369.  
  370. Palace_Room0 = Room(0, Palace_Room0_queue, True, -1)
  371. Palace_Room1 = Room(1, Palace_Room1_queue, True, -1)
  372. Palace_Room2 = Room(2, Palace_Room2_queue, True, -1)
  373.  
  374. """
  375.  
  376. Define the list of Rooms that we consider
  377.  
  378. """
  379.  
  380. Room_List = [Room0, Room1]
  381.  
  382. Oceanside_Room_List = [Oceanside_Room3, Oceanside_Room4]
  383.  
  384. Palace_Room_List = [Palace_Room0, Palace_Room1, Palace_Room2]
  385.  
  386. """
  387.  
  388. In Overlay_dict we collect all of the Overlays of Type A, where the keys are
  389. the corresponding actor ids
  390.  
  391. """
  392.  
  393. # NOTE: This must be named "Overlay_dict" because it is hardcoded in some functions, like the Deallocate() function
  394. Overlay_dict = {
  395. '015A' : Overlay(address=0, Id='015A', size=6000),
  396. '00E8' : Overlay(address=0, Id='00E8', size=1984),
  397. '0170' : Overlay(address=0, Id='0170', size=10688),
  398. '0039' : Overlay(address=0, Id='0039', size=3552),
  399. '0082' : Overlay(address=0, Id='0082', size=9040),
  400. '0158' : Overlay(address=0, Id='0158', size=1104),
  401. '015B' : Overlay(address=0, Id='015B', size=6048),
  402. '0006' : Overlay(address=0, Id='0006', size=8640),
  403. '0017' : Overlay(address=0, Id='0017', size=10432),
  404. '017B' : Overlay(address=0, Id='017B', size=14320),
  405. '007B' : Overlay(address=0, Id='007B', size=5104),
  406. '00A2' : Overlay(address=0, Id='00A2', size=24448),
  407. '02A5' : Overlay(address=0, Id='02A5', size=0x2660),
  408. '0210' : Overlay(address=0, Id='0210', size=0xB90),
  409. '0050' : Overlay(address=0, Id='0050', size=0x3540),
  410. '0125' : Overlay(address=0, Id='0125', size=0x1490),
  411. '01E7' : Overlay(address=0, Id='01E7', size=0x450),
  412. '01F4' : Overlay(address=0, Id='01F4', size=0x1A80),
  413. '020F' : Overlay(address=0, Id='020F', size=0x780),
  414. '0024' : Overlay(address=0, Id='0024', size=0x28E0),
  415. '00E3' : Overlay(address=0, Id='00E3', size=0x420),
  416. '02AE' : Overlay(address=0, Id='02AE', size=0x540),
  417. '01A0' : Overlay(address=0, Id='01A0', size=0xEE0),
  418. '0186' : Overlay(address=0, Id='0186', size=0x950),
  419. '0183' : Overlay(address=0, Id='0183', size=0xD20),
  420. '023B' : Overlay(address=0, Id='023B', size=0x3F0),
  421. '0066' : Overlay(address=0, Id='0066', size=0x1EB0),
  422. '019E' : Overlay(address=0, Id='019E', size=0x5A90),
  423. '01A8' : Overlay(address=0, Id='01A8', size=0x2200),
  424. '00A8' : Overlay(address=0, Id='00A8', size=0x3760),
  425. '0091' : Overlay(address=0, Id='0091', size=0x26C0),
  426. '0092' : Overlay(address=0, Id='0092', size=0x1820),
  427. '017C' : Overlay(address=0, Id='017C', size=0x3110),
  428. '01B9' : Overlay(address=0, Id='01B9', size=0x670),
  429. '0055' : Overlay(address=0, Id='0055', size=0x690),
  430. '013C' : Overlay(address=0, Id='013C', size=0xBF0),
  431. '00FC' : Overlay(address=0, Id='00FC', size=0xC90),
  432. '017A' : Overlay(address=0, Id='017A', size=0xEF0),
  433. '003B' : Overlay(address=0, Id='003B', size=0x2040),
  434. }
  435.  
  436. """
  437.  
  438. Here we collect a list of the actors that we allow ourselves to spawn
  439.  
  440. Notes:
  441. 'Zora Fins' means 2 fins
  442. 'Bugs' means a set of 3 bugs
  443.  
  444.  
  445. """
  446.  
  447. Allocation_List = [
  448. 'Nothing',
  449. 'Bomb',
  450. 'Smoke',
  451. 'Arrow',
  452. 'Hookshot',
  453. 'Charged Spin Attack',
  454. 'Chu',
  455. 'Zora Fins',
  456. 'Fish',
  457. 'Bugs'
  458. ]
  459.  
  460. ######
  461.  
  462.  
  463. """
  464.  
  465. NOTE: We NEED to have 'Hookshot' and 'Charged Spin Attack' as the last two options
  466. in order to consider all cases
  467.  
  468. Don't have 'Bomb' before 'Smoke' to ensure that the Smoke always gets allocated first
  469.  
  470. maybe in the future you could jumble/randomize the order of things in this list at each step
  471. of the solver
  472.  
  473. """
  474. Hardcoded_Allocation_List = [
  475. 'Smoke',
  476. 'Smoke',
  477. 'Smoke',
  478. 'Chu',
  479. 'Chu',
  480. 'Chu',
  481. 'Arrow',
  482. 'Arrow',
  483. 'Arrow',
  484. 'Arrow',
  485. 'Arrow',
  486. 'Bomb',
  487. 'Bomb',
  488. 'Bomb',
  489. 'Zora Fins',
  490. 'Fish',
  491. 'Fish',
  492. 'Bugs',
  493. 'Bugs',
  494. 'Hookshot',
  495. 'Charged Spin Attack'
  496. ]
  497.  
  498. """
  499.  
  500. Here we collect a list of the Ids grabbable actors that we can use for superslide SRM
  501. So far this includes:
  502.  
  503. 0082: Pot
  504.  
  505. """
  506.  
  507. Grabbable_Actors = ['0082']
  508.  
  509.  
  510. """
  511.  
  512. Here we collect a list of Actor Ids for spawners. So far this includes:
  513.  
  514. 00E8: Rupee Cluster
  515.  
  516. """
  517.  
  518. Spawner_Ids = ['00E8']
  519.  
  520.  
  521. """
  522.  
  523. We initialize the Heap as a list, putting a node with address 0x40B140 in the 0th entry
  524. and we place a dummy node at the end of the Heap so that there will always exist two
  525. consecutive nodes for us to define a condition for which free space in the Heap exists
  526.  
  527. Keep in mind that the 0x5FFFFF address in the dummy node will not reflect the actual
  528. address of the corresponding node in-game, but it also isn't relevant to heap manipulation
  529. since it is so far down
  530.  
  531. """
  532.  
  533.  
  534. Heap = [Node(0x40B140, node_size), Node(0x5FFFFF, node_size)]
  535.  
  536.  
  537.  
  538. def Overlay_In_Heap(Heap, overlay):
  539.  
  540. """
  541.  
  542. Overlay is the overlay that we want to check whether or not it is in the Heap
  543.  
  544. This function will return True if Overlay is in the Heap and False otherwise
  545.  
  546. """
  547.  
  548. overlay_in_heap = False
  549.  
  550. for entry in Heap:
  551.  
  552. if type(entry) == Overlay and entry.Id == overlay.Id:
  553.  
  554. overlay_in_heap = True
  555.  
  556. return overlay_in_heap
  557.  
  558.  
  559. def Actor_Id_In_Heap(Heap, actor_id):
  560.  
  561. """
  562.  
  563. actor_id is the Id that we want to check for
  564.  
  565. This function will return True if there exists an Actor in the Heap that
  566. has actor_id as its Id and it will return False otherwise
  567.  
  568. """
  569.  
  570. actor_id_in_heap = False
  571.  
  572. for entry in Heap:
  573.  
  574. if type(entry) == Actor and entry.Id == actor_id:
  575.  
  576. actor_id_in_heap = True
  577.  
  578. return actor_id_in_heap
  579.  
  580.  
  581. def Find_Gaps(Heap):
  582.  
  583. """
  584.  
  585. This function will find all consecutive nodes and output a list of 4-tuples
  586. where the first two entries correspond to the indices of each node in the list
  587. and the last two entries correspond to the addresses of each node
  588.  
  589. The list should be in order, from the start of the Heap to the end of the Heap
  590.  
  591. """
  592.  
  593. consecutive_node_count = 0
  594.  
  595. node_1_address = 0
  596. node_2_address = 0
  597. node_1_index = 0
  598. node_2_index = 0
  599.  
  600. consecutive_node_list = []
  601. for entry in Heap:
  602. if type(entry) == Node and consecutive_node_count == 0:
  603. node_1_address = entry.address
  604. node_1_index = Heap.index(entry)
  605. consecutive_node_count += 1
  606. elif type(entry) == Node and consecutive_node_count == 1:
  607. node_2_address = entry.address
  608. node_2_index = Heap.index(entry)
  609.  
  610. consecutive_node_list.append((node_1_index, node_2_index, node_1_address, node_2_address))
  611.  
  612. consecutive_node_count += 1
  613. elif type(entry) != Node:
  614. consecutive_node_count = 0
  615. elif type(entry) == Node and consecutive_node_count > 1:
  616. consecutive_node_count += 1
  617. print("ERROR: More than 2 consecutive nodes!! (Find_Gaps() Error Message)")
  618.  
  619.  
  620. return consecutive_node_list
  621.  
  622.  
  623.  
  624.  
  625. def Allocate(Heap, actor, Overlay_Dict):
  626.  
  627. """
  628.  
  629. actor is the actor that we want to allocate into the Heap
  630.  
  631. Overlay_Dict is a dictionary where the keys are the actor ids which point to the corresponding Overlays
  632.  
  633. This function will account for placing nodes and overlays
  634.  
  635. """
  636.  
  637.  
  638. #Overlay = Overlay_Dict[actor.Id]
  639.  
  640. #Overlay_Allocated = False
  641.  
  642. #if Overlay_In_Heap(Heap, Overlay) == True:
  643. # Overlay_Allocated = True
  644.  
  645. Actor_Allocated = False
  646.  
  647. """
  648. ##### Not yet defined, not sure if I will bother; not really necessary. Probably should for debugging
  649. if Actor_In_Heap == True:
  650. print('Error: This Actor is already allocated!! (Error message from Allocate() function)')
  651. """
  652.  
  653. gap_list = Find_Gaps(Heap)
  654.  
  655. # Because we initialize the Heap with 2 nodes, there should always be at least one gap
  656. if len(gap_list) < 1:
  657. print('ERROR: len(gap_list) < 1 in Allocate() function')
  658.  
  659.  
  660. # If the Overlay is type A and the Overlay is not already in the Heap, then we want to allocate the overlay first
  661. if actor.overlay_type == 'A':
  662.  
  663. ##### We only define Overlay for Type A overlays because Overlay_Dict only has Type A overlays
  664. Overlay = Overlay_Dict[actor.Id]
  665. Overlay_Allocated = False
  666.  
  667. if Overlay_In_Heap(Heap, Overlay) == True:
  668. Overlay_Allocated = True
  669.  
  670.  
  671. if Overlay_In_Heap(Heap, Overlay) == False:
  672.  
  673. for gap in gap_list:
  674.  
  675. if Overlay_Allocated == True:
  676. break ##### This ensures we don't add in the same Overlay multiple times
  677.  
  678. node_2_index = gap[1]
  679. node_1_address = gap[2]
  680. node_2_address = gap[3]
  681.  
  682. gap_size = node_2_address - node_1_address - node_size
  683.  
  684. ##### Case 1: the Overlay can fit, but there is NOT enough space for an extra node
  685. # Note that gap_size is always a multiple of 16
  686.  
  687. if Overlay.size <= gap_size and Overlay.size > gap_size - 2*node_size:
  688.  
  689. Overlay.address = node_1_address + node_size
  690. Heap.insert(node_2_index, Overlay)
  691. Overlay_Allocated = True
  692.  
  693.  
  694. ##### Case 2: the Overlay can fit and a new node can also fit
  695.  
  696. elif Overlay.size <= gap_size and Overlay.size <= gap_size - 2*node_size:
  697.  
  698. Overlay.address = node_1_address + node_size
  699. Heap.insert(node_2_index, Overlay)
  700.  
  701. ########### ADD IN THE NODE HERE
  702. if Overlay.size%16 > 0:
  703. Heap.insert(node_2_index + 1, Node(address=Overlay.address + Overlay.size + (16 - Overlay.size%16), size=node_size))
  704. elif Overlay.size%16 == 0:
  705. Heap.insert(node_2_index + 1, Node(address=Overlay.address + Overlay.size, size=node_size))
  706.  
  707. Overlay_Allocated = True
  708.  
  709. ############ Now the overlay (if applicable) has been allocated. Now we need to allocate the actor.
  710.  
  711. ##### We need to update the gaps_list to account for the overlay being allocated in the Heap already
  712. gap_list = Find_Gaps(Heap)
  713.  
  714. for gap in gap_list:
  715.  
  716. if Actor_Allocated == True:
  717. break ##### This ensures we don't add in the same Actor multiple times
  718.  
  719. node_2_index = gap[1]
  720. node_1_address = gap[2]
  721. node_2_address = gap[3]
  722.  
  723. gap_size = node_2_address - node_1_address - node_size
  724.  
  725. ##### Case 1: the Actor can fit, but there is NOT enough space for an extra node
  726. # Note that gap_size is always a multiple of 16
  727.  
  728. if actor.size <= gap_size and actor.size > gap_size - 2*node_size:
  729.  
  730. actor.address = node_1_address + node_size
  731. Heap.insert(node_2_index, actor)
  732. Actor_Allocated = True
  733.  
  734.  
  735. ##### Case 2: the Actor can fit and a new node can also fit
  736.  
  737. elif actor.size <= gap_size and actor.size <= gap_size - 2*node_size:
  738.  
  739. actor.address = node_1_address + node_size
  740. Heap.insert(node_2_index, actor)
  741.  
  742. ########### ADD IN THE NODE HERE
  743. if actor.size%16 > 0:
  744. Heap.insert(node_2_index + 1, Node(address=actor.address + actor.size + (16 - actor.size%16), size=node_size))
  745. elif actor.size%16 == 0:
  746. Heap.insert(node_2_index + 1, Node(address=actor.address + actor.size, size=node_size))
  747.  
  748. Actor_Allocated = True
  749.  
  750. def Borders_Node(Heap, entry):
  751.  
  752. """
  753.  
  754. This function takes an entry of the Heap as input and determines whether or
  755. not this entry is adjacent to a node in the heap (the purpose of this is to
  756. check if a node is bordering another node since actors and overlays should
  757. be bordering two nodes under every circumstance)
  758.  
  759. Returns True if the entry is bordering a node, returns False otherwise
  760.  
  761. """
  762.  
  763. borders_node = False
  764.  
  765. entry_index = Heap.index(entry)
  766.  
  767. border_1_is_node = False
  768. border_2_is_node = False
  769.  
  770. if entry_index != 0:
  771. border_1 = Heap[entry_index - 1]
  772. if type(border_1) == Node:
  773. border_1_is_node = True
  774.  
  775. if entry_index != len(Heap) - 1:
  776. border_2 = Heap[entry_index + 1]
  777. if type(border_2) == Node:
  778. border_2_is_node = True
  779.  
  780. if border_1_is_node == True or border_2_is_node == True:
  781. borders_node = True
  782.  
  783. return borders_node
  784.  
  785.  
  786.  
  787. def Deallocate(Heap, actor, Overlay_dict):
  788.  
  789.  
  790. """
  791.  
  792. actor is the actor that we want to be deallocated from the Heap
  793.  
  794. This function will account for removing nodes and overlays
  795.  
  796. ##### Remove the actor AND node if applicable
  797. ##### Check if any actors with the same Id are still in the Heap
  798. ##### if not (and the actor has overlay Type A), then remove the overlay
  799.  
  800. We only remove a node if it is part of a gap before deallocating the actor
  801. That is, we only remove a node if it borders another node before the actor is deallocated
  802.  
  803. """
  804.  
  805. if type(actor) != Actor:
  806. print("ERROR: Attempted to deallocate something other than an Actor (Deallocate() function error message)")
  807.  
  808. # The index of where the actor is in the Heap before being deallocated; this will change after we remove the first node
  809. actor_index = Heap.index(actor)
  810.  
  811. ##### First check the node above the actor in the Heap
  812. node_1 = Heap[actor_index - 1]
  813. if type(node_1) != Node:
  814. print("ERROR: One of the nodes is not actually a node! (Deallocate() function error message)")
  815.  
  816. if Borders_Node(Heap, node_1) == True:
  817. Heap.remove(node_1)
  818.  
  819. ########## Now the first node has been removed and the indices of the Heap shift
  820.  
  821. ##### Now we check the node below the actor in the Heap
  822.  
  823. # The index of where the actor is in the Heap before being deallocated; this will change after we remove the first node
  824. actor_index = Heap.index(actor)
  825.  
  826. node_2 = Heap[actor_index + 1]
  827. if type(node_2) != Node:
  828. print("ERROR: One of the nodes is not actually a node! (Deallocate() function error message)")
  829.  
  830. if Borders_Node(Heap, node_2) == True:
  831. Heap.remove(node_2)
  832.  
  833. ###########################################################################
  834. ##### Now we have removed both of the nodes, if applicable and we must remove the actor itself
  835.  
  836. Heap.remove(actor)
  837.  
  838. """
  839.  
  840. Now if the actor has a Type A overlay, then we must check if the Heap contains
  841. any other actors that have the same Id as actor and if not, then we must also
  842. remove its overlay from the Heap
  843.  
  844. We must also account for removing the nodes around the overlay, if applicable
  845.  
  846. """
  847.  
  848. if actor.overlay_type == 'A' and Actor_Id_In_Heap(Heap, actor.Id) == False:
  849.  
  850. ##### First check the node above the overlay
  851. overlay_index = Heap.index(Overlay_dict[actor.Id])
  852. node1 = Heap[overlay_index - 1]
  853.  
  854. if type(node1) != Node:
  855. print("ERROR: One of the nodes is not actually a node! (Deallocate() function error message)")
  856.  
  857. if Borders_Node(Heap, node1) == True:
  858. Heap.remove(node1)
  859.  
  860.  
  861. ##### Now we check the node below the overlay
  862. overlay_index = Heap.index(Overlay_dict[actor.Id])
  863. node2 = Heap[overlay_index + 1]
  864.  
  865. if type(node2) != Node:
  866. print("ERROR: One of the nodes is not actually a node! (Deallocate() function error message)")
  867.  
  868. if Borders_Node(Heap, node2) == True:
  869. Heap.remove(node2)
  870.  
  871. ###########################################################################
  872. ##### Now we have removed both of the nodes, if applicable and we must remove the overlay itself
  873.  
  874. Heap.remove(Overlay_dict[actor.Id])
  875.  
  876.  
  877.  
  878. def Load_Scene(Heap, room, Overlay_dict):
  879.  
  880. if len(Heap) != 2:
  881. print("ERROR: Attempted to use Load_Scene() with an inappropriate Heap")
  882.  
  883. entry_count = 0
  884. for entry in room.priority_queue:
  885.  
  886. ##### If the clock is not in the room's set of actors, then we must allocate the clock at the appropriate time when we load the scene
  887. if entry_count == room.clock_priority and room.clock_exists == False:
  888.  
  889. ##### Allocate the 3-Day Clock actor
  890. Allocate(Heap, Clock, Overlay_dict)
  891. entry_count += 1
  892.  
  893. ##### Allocate the entry in the room's priority queue
  894. Allocate(Heap, entry, Overlay_dict)
  895.  
  896. entry_count += 1
  897.  
  898. ##### Now that all of the actors have been allocated, we want to add in all of the actors that the spawners spawn
  899.  
  900. """
  901.  
  902. NOTE: THIS DOES NOT HANDLE SPAWNERS OTHER THAN RUPEE CLUSTERS AT THE MOMENT
  903.  
  904. In the future, it will need to be considered how the actors created by spawners
  905. prioritize over each other... Spring MV is maybe the only place where this really matters
  906.  
  907. """
  908.  
  909. ##### Check for Rupee Cluster
  910. if Overlay_In_Heap(Heap, Overlay_dict['00E8']) == True:
  911.  
  912. for j in range(7):
  913. rupee = Actor(name='Collectible (Rupee from Rupee Cluster)', Id='000E', size=424, category=0, overlay_type='B', unloadable=True, address=0, room_number=room.number, priority=j, from_spawner=True, transition=False, clearable=True, cleared=False)
  914.  
  915. Allocate(Heap, rupee, Overlay_dict)
  916.  
  917.  
  918.  
  919. def Actor_From_Room_In_Heap(Heap, Room_Number):
  920.  
  921. """
  922.  
  923. This function takes the Heap and the number of the Room in question as input
  924. It returns True if there exists an Actor in the Heap with the inputted Room_Number and False otherwise
  925.  
  926. """
  927.  
  928. actor_from_room_in_heap = False
  929.  
  930. for entry in Heap:
  931.  
  932. if type(entry) == Actor and entry.room_number is Room_Number:
  933.  
  934. actor_from_room_in_heap = True
  935.  
  936. return actor_from_room_in_heap
  937.  
  938. def Cleared_Actor_In_Heap(Heap):
  939.  
  940. """
  941.  
  942. This function returns True if there is a cleared actor in the Heap and False otherwise
  943.  
  944. """
  945.  
  946. cleared_actor_in_heap = False
  947.  
  948. for entry in Heap:
  949.  
  950. if type(entry) == Actor and entry.cleared == True:
  951.  
  952. cleared_actor_in_heap = True
  953.  
  954. return cleared_actor_in_heap
  955.  
  956.  
  957. def Shared_Transition_Count(Heap, Room_Number_1, Room_Number_2):
  958.  
  959. """
  960.  
  961. This function returns the number of transitions (Planes/Doors) that are shared between
  962. the two rooms with room numbers Room_Number_1 and Room_Number_2
  963.  
  964. """
  965.  
  966. shared_transition_count = 0
  967.  
  968. for entry in Heap:
  969.  
  970. if type(entry) == Actor and entry.transition != False:
  971.  
  972. if (entry.transition[0] == Room_Number_1 and entry.transition[1] == Room_Number_2) or (entry.transition[0] == Room_Number_2 and entry.transition[1] == Room_Number_1):
  973.  
  974. shared_transition_count += 1
  975.  
  976. return shared_transition_count
  977.  
  978. def Is_Shared_Transition(actor, Room_Number_1, Room_Number_2):
  979.  
  980. """
  981.  
  982. If actor is a transition shared between Rooms with numbers Room_Number_1 and Room_Number_2,
  983. then this function returns True. Otherwise it returns False
  984.  
  985. """
  986.  
  987. is_shared_transition = False
  988.  
  989. if type(actor) == Actor and actor.transition != False:
  990.  
  991. if (actor.transition[0] == Room_Number_1 and actor.transition[1] == Room_Number_2) or (actor.transition[0] == Room_Number_2 and actor.transition[1] == Room_Number_1):
  992.  
  993. is_shared_transition = True
  994.  
  995. return is_shared_transition
  996.  
  997.  
  998. def Transition_Is_In_Room(actor, Room_Number):
  999.  
  1000. transition_is_in_room = False
  1001.  
  1002. if type(actor) == Actor and actor.transition != False:
  1003.  
  1004. if actor.transition[0] == Room_Number or actor.transition[1] == Room_Number:
  1005.  
  1006. transition_is_in_room = True
  1007.  
  1008. return transition_is_in_room
  1009.  
  1010.  
  1011. def Find_Clock_List(Heap):
  1012.  
  1013. """
  1014.  
  1015. This function finds all clock actor instances in the Heap and returns a list of them, in order
  1016.  
  1017. """
  1018.  
  1019. clock_list = []
  1020.  
  1021. for entry in Heap:
  1022.  
  1023. if type(entry) == Actor and entry.Id == '015A':
  1024.  
  1025. clock_list.append(entry)
  1026.  
  1027. return clock_list
  1028.  
  1029.  
  1030. def Load_Room(Heap, room, transition, Overlay_dict):
  1031.  
  1032.  
  1033. """
  1034.  
  1035. This function updates the Heap after you enter room through transition
  1036. For example, you might enter Room0 through Plane1 or Door3
  1037.  
  1038. Before executing the script, should probably define Plane1, Plane2, ...
  1039. Door1, Door2, ..., etc. as the corresponding entries from the room queues.
  1040. This will make the code more readable when looking for solutions
  1041.  
  1042.  
  1043. * First we load all of the actors from the new room
  1044. * Next, we deallocate everything (well, not literally everything...) from the previous room
  1045.  
  1046.  
  1047. Things that this function needs to handle:
  1048.  
  1049. - make sure that you check if each actor was cleared or not (if clearable == True, otherwise it isn't applicable)
  1050. and then check if it is Category 5 to determine if it loads and immediately deallocates or not
  1051.  
  1052. - checking which clock to deallocate (i.e. deallocate the one that comes later
  1053. on in the Heap if there are more than one). Maybe define a Find_Clocks function
  1054.  
  1055. - make sure transition never deallocates and never attempts to allocate
  1056.  
  1057. - make sure that the other Transitions unload and then reload (if applicable) after all of
  1058. the stuff from the previous room deallocated
  1059.  
  1060. - when deallocating stuff from the room that isn't the room you're entering, be sure
  1061. not to deallocate the clock. Also be careful of relevant Transitions as they don't have
  1062. actual room numbers (replaced with False)
  1063.  
  1064. - allocate stuff from spawners after the fact (even after planes)
  1065.  
  1066.  
  1067. """
  1068.  
  1069. if transition not in Heap:
  1070. print('2222222222')
  1071.  
  1072. if transition not in room.priority_queue:
  1073. print('44444444')
  1074.  
  1075. if (transition not in Heap) or (transition not in room.priority_queue):
  1076. print("ERROR: Attempted to use Load_Room() with an invalid transition")
  1077.  
  1078. current_room_number = -1
  1079. new_room_number = room.number
  1080.  
  1081. if transition.transition[0] == room.number:
  1082. current_room_number = transition.transition[1]
  1083. elif transition.transition[1] == room.number:
  1084. current_room_number = transition.transition[0]
  1085. else:
  1086. print("ERROR: Error with transition list (Load_Room() error message)")
  1087.  
  1088. """
  1089. First we load all of the actors from the new room, EXCEPT for: the plane/door
  1090. we pass through AND any other shared transitions AND any actors with both
  1091. cleared == True and Category == 5 (these ones never attempt to load)
  1092. """
  1093.  
  1094. for actor in room.priority_queue:
  1095.  
  1096. ### If the actor is not a Transition OR if the actor is a transition but doesn't connect to the current room
  1097. if (actor.transition == False) or (actor.transition != False and actor.transition[0] != current_room_number and actor.transition[1] != current_room_number):
  1098.  
  1099. ### If the actor is Category 5, then only attempt to load it if it has not been cleared
  1100. if actor.category != 5 or actor.cleared == False:
  1101.  
  1102. Allocate(Heap, actor, Overlay_dict)
  1103.  
  1104. """
  1105. - Now all of the relevant actors from the new room have been allocated
  1106. - Now we need to immediately deallocate any actors with Clearable == True and Cleared == True
  1107. - We also need to deallocate any transitions which are shared between the current room and the new room
  1108. EXCEPT for transition itself (the transition that we passed through to get to the new room)
  1109. - We also need to deallocate the second clock actor in the Heap if it exists (do this after everything else for simplicity)
  1110.  
  1111. Note that "current_room_number" is the room number of the room we were in before loading the new room
  1112. """
  1113.  
  1114. while Actor_From_Room_In_Heap(Heap, current_room_number) == True or Cleared_Actor_In_Heap(Heap) == True or Shared_Transition_Count(Heap, current_room_number, new_room_number) > 1:
  1115.  
  1116. for entry in Heap:
  1117.  
  1118. if (type(entry) == Actor) and (entry.room_number is current_room_number or entry.cleared == True or Is_Shared_Transition(entry, current_room_number, new_room_number) == True or (entry.transition != False and Transition_Is_In_Room(entry, new_room_number) == False ) ) and (entry != transition):
  1119.  
  1120. Deallocate(Heap, entry, Overlay_dict)
  1121.  
  1122. ########## Now we will find all of the clocks and deallocate the second clock if it exists (and report error if more than two clocks)
  1123.  
  1124. Clock_List = Find_Clock_List(Heap)
  1125.  
  1126. if len(Clock_List) > 2:
  1127. print("ERROR: More than 2 Clocks in the Actor Heap (Load_Room() Error Message)")
  1128. elif len(Clock_List) < 1:
  1129. print("ERROR: No Clock Actor Instance in the Actor Heap (Load_Room() Error Message)")
  1130.  
  1131. ##### If there are two clocks, then we deallocate the second clock that appears in the Heap
  1132. if len(Clock_List) > 1:
  1133.  
  1134. Deallocate(Heap, Clock_List[1], Overlay_dict)
  1135.  
  1136.  
  1137. ##### Now we allocate any shared transitions EXCEPT for transition itself (the door/plane we entered to get into this room)
  1138.  
  1139. for entry in room.priority_queue:
  1140.  
  1141. # If entry is a shared transition and is NOT the transition that we passed through
  1142. if (type(entry) == Actor) and (entry.transition != False) and Is_Shared_Transition(entry, current_room_number, new_room_number) == True and (entry != transition):
  1143.  
  1144. Allocate(Heap, entry, Overlay_dict)
  1145.  
  1146. ###################################### Now we only have to account for allocating things from spawners
  1147.  
  1148.  
  1149. """
  1150.  
  1151. NOTE: THIS DOES NOT HANDLE SPAWNERS OTHER THAN RUPEE CLUSTERS AT THE MOMENT
  1152.  
  1153. In the future, it will need to be considered how the actors created by spawners
  1154. prioritize over each other... Spring MV is maybe the only place where this really matters
  1155.  
  1156. """
  1157.  
  1158. ##### Check for Rupee Cluster
  1159. if Overlay_In_Heap(Heap, Overlay_dict['00E8']) == True:
  1160.  
  1161. for j in range(7):
  1162. rupee = Actor(name='Collectible (Rupee from Rupee Cluster)', Id='000E', size=424, category=0, overlay_type='B', unloadable=True, address=0, room_number=room.number, priority=j, from_spawner=True, transition=False, clearable=True, cleared=False)
  1163.  
  1164. Allocate(Heap, rupee, Overlay_dict)
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170. def Display_Heap(Heap):
  1171.  
  1172. for entry in Heap:
  1173.  
  1174. if type(entry) == Node:
  1175.  
  1176. print(hex(entry.address) + '-----' + 'NODE-----------------')
  1177.  
  1178. elif type(entry) == Overlay:
  1179.  
  1180. print(hex(entry.address) + ' ' + entry.Id + ' ' + 'OVERLAY')
  1181.  
  1182. elif type(entry) == Actor:
  1183.  
  1184. print(hex(entry.address) + ' ' + entry.Id + ' ' + 'INSTANCE')
  1185.  
  1186. else:
  1187. print("ERROR!!! Unexpected Entry Type in Heap!!!!!!!!!")
  1188.  
  1189.  
  1190. ###############################################################################
  1191. ###############################################################################
  1192. ###############################################################################
  1193. ###############################################################################
  1194. ###############################################################################
  1195. ###############################################################################
  1196.  
  1197. def Allocate_Fish(Heap, Room_Number, Overlay_dict):
  1198.  
  1199. Fish = Actor(name='Fish', Id='0017', size=636, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1200.  
  1201. Allocate(Heap, Fish, Overlay_dict)
  1202.  
  1203.  
  1204. def Allocate_Bugs(Heap, Room_Number, Overlay_dict):
  1205.  
  1206. """
  1207.  
  1208. This function allocates a set of 3 bugs to the Heap
  1209.  
  1210. """
  1211.  
  1212. for i in range(3):
  1213. Bug = Actor(name='Bug', Id='017B', size=884, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=i, from_spawner=False, transition=False, clearable=False, cleared=False)
  1214.  
  1215. Allocate(Heap, Bug, Overlay_dict)
  1216.  
  1217.  
  1218. def Allocate_Bomb(Heap, Room_Number, Overlay_dict):
  1219.  
  1220. Bomb = Actor(name='Bomb', Id='0009', size=516, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1221.  
  1222. Allocate(Heap, Bomb, Overlay_dict)
  1223.  
  1224.  
  1225. def Allocate_Smoke(Heap, Room_Number, Overlay_dict):
  1226.  
  1227. """
  1228.  
  1229. This function allocates a bomb, then allocates smoke (this happens when the bomb explodes)
  1230. and then deallocates the bomb (we bothered allocating the bomb to ensure that the smoke
  1231. appears in the right spot in the Heap)
  1232.  
  1233. Note that we should never allow ourselves to allocate smoke AFTER calling Allocate_Bomb()
  1234. because in reality the first bomb would explode first (this isn't strictly true, but we should
  1235. do it this way at least in the simple script)
  1236.  
  1237. """
  1238.  
  1239. Bomb = Actor(name='Bomb', Id='0009', size=516, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1240.  
  1241. Allocate(Heap, Bomb, Overlay_dict)
  1242.  
  1243. Smoke = Actor(name='Smoke', Id='00A2', size=11908, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1244.  
  1245. Allocate(Heap, Smoke, Overlay_dict)
  1246.  
  1247. Deallocate(Heap, Bomb, Overlay_dict)
  1248.  
  1249. def Allocate_Arrow(Heap, Room_Number, Overlay_dict):
  1250.  
  1251. """
  1252.  
  1253. This function allocates an arrow into the heap. Note that Deku Bubbles are
  1254. the same actor as arrows (in that they're both 000F)
  1255.  
  1256. """
  1257.  
  1258. Arrow = Actor(name='Arrow', Id='000F', size=632, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1259.  
  1260. Allocate(Heap, Arrow, Overlay_dict)
  1261.  
  1262.  
  1263. def Allocate_Hookshot(Heap, Room_Number, Overlay_dict):
  1264.  
  1265. Hookshot = Actor(name='Hookshot', Id='003D', size=528, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1266.  
  1267. Allocate(Heap, Hookshot, Overlay_dict)
  1268.  
  1269.  
  1270. def Allocate_Chu(Heap, Room_Number, Overlay_dict):
  1271.  
  1272. Chu = Actor(name='Chu', Id='006A', size=480, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1273.  
  1274. Allocate(Heap, Chu, Overlay_dict)
  1275.  
  1276.  
  1277. def Allocate_Square_Sign(Heap, Room_Number, Overlay_dict):
  1278.  
  1279. Sign = Actor(name='Square Sign', Id='00A8', size=0x1F0, category=0, overlay_type='A', unloadable=False, address=0, room_number=Room_Number, priority=999, from_spawner=False, transition=False, clearable=False, cleared=False)
  1280.  
  1281. Allocate(Heap, Sign, Overlay_dict)
  1282.  
  1283.  
  1284. def Allocate_Zora_Fins(Heap, Room_Number, Overlay_dict):
  1285.  
  1286. """
  1287.  
  1288. This function allocates 2 Zora Fin actor instances
  1289.  
  1290. """
  1291.  
  1292. for i in range(2):
  1293.  
  1294. Zora_Fin = Actor(name='Zora Fin', Id='0020', size=500, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1295.  
  1296. Allocate(Heap, Zora_Fin, Overlay_dict)
  1297.  
  1298.  
  1299. def Allocate_Charged_Spin_Attack(Heap, Room_Number, Overlay_dict):
  1300.  
  1301. """
  1302.  
  1303. This functions allocates the Spin Attack & Sword Beam Effects and then the
  1304. Spin Attack Charge Particles (This is the order they get allocated in when
  1305. you charge a spin attack)
  1306.  
  1307. """
  1308.  
  1309. Spin_Attack_and_Sword_Beam_Effects = Actor(name='Spin Attack & Sword Beam Effects', Id='0035', size=452, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1310.  
  1311. Allocate(Heap, Spin_Attack_and_Sword_Beam_Effects, Overlay_dict)
  1312.  
  1313. Spin_Attack_Charge_Particles = Actor(name='Spin Attack Charge Particles', Id='007B', size=1367, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1314.  
  1315. Allocate(Heap, Spin_Attack_Charge_Particles, Overlay_dict)
  1316.  
  1317.  
  1318.  
  1319.  
  1320. def Allocate_Gold_Skulltula_With_Hookshot(Heap, Room_Number, Overlay_dict):
  1321.  
  1322. """
  1323.  
  1324. This function allocates a gold skulltula (for example, if you shoot a skull-
  1325. kid painting that reveals a gold skulltula, it allocates a gold skulltula)
  1326.  
  1327. It first allocates an hookshot, then the gold skulltula, then deallocates the hookshot
  1328.  
  1329. THIS FUNCTION HARDCODES THE PRIORITY OF THE GOLD SKULLTULA TO BE 5 BECAUSE
  1330. I ONLY CARE ABOUT ROOM 3 OF OCEANSIDE SPIDERHOUSE
  1331.  
  1332. """
  1333.  
  1334. Gold_Skulltula = Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=5, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=5, from_spawner=False, transition=False, clearable=True, cleared=False)
  1335.  
  1336. if Gold_Skulltula.room_number != 3:
  1337. print("ERROR: Gold_Skulltula has room_number != 3 ?????? (Allocate_Gold_Skulltula() Error Message)")
  1338.  
  1339.  
  1340. Hookshot = Actor(name='Hookshot', Id='003D', size=528, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1341.  
  1342. Allocate(Heap, Hookshot, Overlay_dict)
  1343.  
  1344. Allocate(Heap, Gold_Skulltula, Overlay_dict)
  1345.  
  1346. Deallocate(Heap, Hookshot, Overlay_dict)
  1347.  
  1348.  
  1349. def Allocate_Gold_Skulltula_With_Arrow(Heap, Room_Number, Overlay_dict):
  1350.  
  1351. """
  1352.  
  1353. This function allocates a gold skulltula (for example, if you shoot a skull-
  1354. kid painting that reveals a gold skulltula, it allocates a gold skulltula)
  1355.  
  1356. It first allocates an arrow, then the gold skulltula, then deallocates the arrow
  1357.  
  1358. THIS FUNCTION HARDCODES THE PRIORITY OF THE GOLD SKULLTULA TO BE 5 BECAUSE
  1359. I ONLY CARE ABOUT ROOM 3 OF OCEANSIDE SPIDERHOUSE
  1360.  
  1361. """
  1362.  
  1363. Gold_Skulltula = Actor(name='Gold Skulltula', Id='0050', size=0x4A4, category=5, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=5, from_spawner=False, transition=False, clearable=True, cleared=False)
  1364.  
  1365. if Gold_Skulltula.room_number != 3:
  1366. print("ERROR: Gold_Skulltula has room_number != 3 ?????? (Allocate_Gold_Skulltula() Error Message)")
  1367.  
  1368.  
  1369. Arrow = Actor(name='Arrow', Id='000F', size=632, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1370.  
  1371. Allocate(Heap, Arrow, Overlay_dict)
  1372.  
  1373. Allocate(Heap, Gold_Skulltula, Overlay_dict)
  1374.  
  1375. Deallocate(Heap, Arrow, Overlay_dict)
  1376.  
  1377.  
  1378. def Kill_Gold_Skulltula(Heap, Gold_Skulltula, Room_Number, Overlay_dict):
  1379.  
  1380. """
  1381.  
  1382. TODO: can implement this for more oceanside possibilties
  1383.  
  1384. This function kills a gold skulltula to spawn a gold skulltula token
  1385. WITHOUT using something that spawns an actor (like hookshot or an arrow)
  1386.  
  1387.  
  1388. it matters how you kill it because the token needs to allocate (hookshot, arrow, sword, fins)
  1389.  
  1390. """
  1391.  
  1392. if Gold_Skulltula.Id != '0050':
  1393. print("ERROR: Gold_Skulltula is not actually a gold skulltula (Kill_Gold_Skulltula() Error Message)")
  1394.  
  1395. Gold_Skulltula_Token = Actor(name='Gold Skulltula Token', Id='00E3', size=0x1A0, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=Gold_Skulltula.priority, from_spawner=False, transition=False, clearable=True, cleared=False)
  1396.  
  1397. Allocate(Heap, Gold_Skulltula_Token, Overlay_dict)
  1398.  
  1399. Deallocate(Heap, Gold_Skulltula, Overlay_dict)
  1400.  
  1401.  
  1402. def Kill_Gold_Skulltula_With_Hookshot(Heap, Gold_Skulltula, Room_Number, Overlay_dict):
  1403.  
  1404. """
  1405.  
  1406. TODO: can implement this for more oceanside possibilties
  1407.  
  1408. This function kills a gold skulltula to spawn a gold skulltula token with hookshot
  1409.  
  1410.  
  1411. it matters how you kill it because the token needs to allocate (hookshot, arrow, sword, fins)
  1412.  
  1413. """
  1414.  
  1415. if Gold_Skulltula.Id != '0050':
  1416. print("ERROR: Gold_Skulltula is not actually a gold skulltula (Kill_Gold_Skulltula_With_Hookshot() Error Message)")
  1417.  
  1418. Gold_Skulltula_Token = Actor(name='Gold Skulltula Token', Id='00E3', size=0x1A0, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=Gold_Skulltula.priority, from_spawner=False, transition=False, clearable=True, cleared=False)
  1419.  
  1420. Hookshot = Actor(name='Hookshot', Id='003D', size=528, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1421.  
  1422. Allocate(Heap, Hookshot, Overlay_dict)
  1423.  
  1424. Allocate(Heap, Gold_Skulltula_Token, Overlay_dict)
  1425.  
  1426. Deallocate(Heap, Gold_Skulltula, Overlay_dict)
  1427.  
  1428. Deallocate(Heap, Hookshot, Overlay_dict)
  1429.  
  1430.  
  1431. def Kill_Gold_Skulltula_With_Arrow(Heap, Gold_Skulltula, Room_Number, Overlay_dict):
  1432.  
  1433. """
  1434.  
  1435. TODO: can implement this for more oceanside possibilties
  1436.  
  1437. This function kills a gold skulltula to spawn a gold skulltula token with hookshot
  1438.  
  1439.  
  1440. it matters how you kill it because the token needs to allocate (hookshot, arrow, sword, fins)
  1441.  
  1442. """
  1443.  
  1444. if Gold_Skulltula.Id != '0050':
  1445. print("ERROR: Gold_Skulltula is not actually a gold skulltula (Kill_Gold_Skulltula_With_Arrow() Error Message)")
  1446.  
  1447. Gold_Skulltula_Token = Actor(name='Gold Skulltula Token', Id='00E3', size=0x1A0, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=Gold_Skulltula.priority, from_spawner=False, transition=False, clearable=True, cleared=False)
  1448.  
  1449. Arrow = Actor(name='Arrow', Id='000F', size=632, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  1450.  
  1451. Allocate(Heap, Arrow, Overlay_dict)
  1452.  
  1453. Allocate(Heap, Gold_Skulltula_Token, Overlay_dict)
  1454.  
  1455. Deallocate(Heap, Gold_Skulltula, Overlay_dict)
  1456.  
  1457. Deallocate(Heap, Arrow, Overlay_dict)
  1458.  
  1459.  
  1460.  
  1461. """
  1462.  
  1463. Before proceeding, we should define all of the transitions we plan on passing through
  1464.  
  1465. Since "Beneath the Graveyard" is relatively simple and I currently only want to consider
  1466. passing through a single plane, I will just define Plane_1 to be the plane shared between
  1467. Room0 and Room1
  1468.  
  1469. This loading plane happens the be the second element in Room0_queue, so I will define it based on that
  1470.  
  1471. """
  1472.  
  1473. Plane_1 = Room0_queue[1]
  1474.  
  1475.  
  1476. Transition_List= [Plane_1]
  1477.  
  1478.  
  1479. """
  1480.  
  1481. Grabbable_dict is a dictionary of the grabbable actors (such as pots) that
  1482. we want to attempt to use for superslide SRM where the keys are the grabbable
  1483. actors and the values are lists with 3-bit strings where each bit means:
  1484.  
  1485. 100 : Possible to enter Plane with both Bomb and Smoke loaded
  1486. 010 : Possible to enter Plane with Smoke loaded, but no Bomb loaded
  1487. 001 : Possible to enter Plane with no Smoke loaded
  1488.  
  1489. and Transitions, where the transitions are the ones you can superslide through
  1490.  
  1491.  
  1492.  
  1493. """
  1494.  
  1495. Grabbable_dict = {
  1496. Room0_queue[6] : ['100', Plane_1],
  1497. Room0_queue[7] : ['100', Plane_1],
  1498. Room1_queue[25] : ['110', Plane_1],
  1499. Room1_queue[26] : ['100', Plane_1],
  1500. Room1_queue[27] : ['011', Plane_1]
  1501. }
  1502.  
  1503.  
  1504. """
  1505.  
  1506. Below this we can consider a sequence of Room loads and then display the Heap
  1507.  
  1508. """
  1509.  
  1510.  
  1511. #Load_Scene(Heap, Room0)
  1512.  
  1513.  
  1514. #Load_Room(Heap, Room1, Plane_1, Overlay_dict)
  1515.  
  1516. #Load_Room(Heap, Room0, Plane_1, Overlay_dict)
  1517.  
  1518. #Load_Room(Heap, Room1, Plane_1, Overlay_dict)
  1519.  
  1520. #Load_Room(Heap, Room0, Plane_1, Overlay_dict)
  1521.  
  1522.  
  1523. #Display_Heap(Heap)
  1524.  
  1525. ###############################################################################
  1526. ###############################################################################
  1527. ###############################################################################
  1528. ###############################################################################
  1529. ###############################################################################
  1530. ###############################################################################
  1531.  
  1532.  
  1533. def Grabbable_In_Room(room, grabbable_actor_list):
  1534.  
  1535. """
  1536.  
  1537. This function checks the inputted room to see if it contains a grabbale actor
  1538. that we can use for the superslide for SRM (in theory at least...)
  1539.  
  1540. """
  1541.  
  1542. grabbable_in_room = False
  1543.  
  1544. for actor in room.priority_queue:
  1545.  
  1546. if type(actor) == Actor and actor.Id in grabbable_actor_list:
  1547.  
  1548. grabbable_in_room = True
  1549.  
  1550. return grabbable_in_room
  1551.  
  1552.  
  1553. def Valid_Grabbable_In_Room(room, grabbable_actor_dict):
  1554.  
  1555. """
  1556.  
  1557. This function checks the inputted room to see if it contains a grabbale actor
  1558. that we can use for the superslide for SRM
  1559.  
  1560. """
  1561.  
  1562. valid_grabbable_in_room = False
  1563.  
  1564. for actor in room.priority_queue:
  1565.  
  1566. if actor in grabbable_actor_dict.keys():
  1567.  
  1568. valid_grabbable_in_room = True
  1569.  
  1570. return valid_grabbable_in_room
  1571.  
  1572.  
  1573. def Chest_In_Room(room):
  1574.  
  1575. """
  1576.  
  1577. This function checks the inputted room to see if it contains a chest
  1578.  
  1579. """
  1580.  
  1581. chest_in_room = False
  1582.  
  1583. for actor in room.priority_queue:
  1584.  
  1585. if type(actor) == Actor and actor.Id == '0006':
  1586.  
  1587. chest_in_room = True
  1588.  
  1589. return chest_in_room
  1590.  
  1591.  
  1592. def Deku_Guard_In_Room(room):
  1593.  
  1594. """
  1595.  
  1596. This function checks the inputted room to see if it contains a Deku Guard
  1597.  
  1598. """
  1599.  
  1600. deku_guard_in_room = False
  1601.  
  1602. for actor in room.priority_queue:
  1603.  
  1604. if type(actor) == Actor and actor.Id == '017A':
  1605.  
  1606. deku_guard_in_room = True
  1607.  
  1608. return deku_guard_in_room
  1609.  
  1610.  
  1611. def Transition_List(room):
  1612.  
  1613. """
  1614.  
  1615. This function takes a room as input and returns a list of all of its transitions
  1616. (i.e. doors/loading planes that lead to other rooms)
  1617.  
  1618. """
  1619.  
  1620. transition_list = []
  1621.  
  1622. for actor in room.priority_queue:
  1623.  
  1624. if actor.transition != False:
  1625.  
  1626. transition_list.append(actor)
  1627.  
  1628. return transition_list
  1629.  
  1630.  
  1631. def Shared_Transitions(room1, room2):
  1632.  
  1633. """
  1634.  
  1635. This function takes two Rooms as input and returns a list of their shared transitions
  1636. (essentially returns the edges connecting these rooms if we view the rooms are nodes
  1637. in a graph)
  1638.  
  1639. """
  1640.  
  1641. shared_transitions = []
  1642.  
  1643. for transition in Transition_List(room1):
  1644.  
  1645. if Is_Shared_Transition(transition, room1.number, room2.number) == True:
  1646.  
  1647. shared_transitions.append(transition)
  1648.  
  1649. return shared_transitions
  1650.  
  1651.  
  1652. def Shared_Transition_Exists(room1, room2):
  1653.  
  1654. """
  1655.  
  1656. This function takes two Rooms as input and returns True if they share a transition
  1657. and False otherwise
  1658.  
  1659. """
  1660.  
  1661. shared_transition_exists = False
  1662.  
  1663. for transition in Transition_List(room1):
  1664.  
  1665. if Is_Shared_Transition(transition, room1.number, room2.number) == True:
  1666.  
  1667. shared_transition_exists = True
  1668.  
  1669. return shared_transition_exists
  1670.  
  1671.  
  1672. def Neighbors(room, Room_List):
  1673.  
  1674. """
  1675.  
  1676. This function takes a room as input along with a list of all potential rooms
  1677. and returns a list of all rooms that share a transition with this room (excluding itself)
  1678.  
  1679. """
  1680.  
  1681. neighbors = []
  1682.  
  1683. for ROOM in Room_List:
  1684.  
  1685. if ROOM != room and Shared_Transition_Exists(room, ROOM) == True:
  1686.  
  1687. neighbors.append(ROOM)
  1688.  
  1689. return neighbors
  1690.  
  1691.  
  1692. def New_Room(room, transition, Room_List):
  1693.  
  1694. """
  1695.  
  1696. This function takes a room, a transition, and a list of all available rooms
  1697. as input and returns the room that you would be in if you started in room
  1698. and passed through transition
  1699.  
  1700. """
  1701.  
  1702. if transition not in Transition_List(room):
  1703. print("ERROR: Invalid input into New_Room() function; transition is not in room")
  1704.  
  1705. for ROOM in Room_List:
  1706.  
  1707. if ROOM != room and (transition.transition[0] == ROOM.number or transition.transition[1] == ROOM.number) and ROOM.number != room.number:
  1708.  
  1709. new_room = ROOM
  1710.  
  1711. return new_room
  1712.  
  1713.  
  1714. def Current_Room(Room_Load_Permutation, Room_List):
  1715.  
  1716. """
  1717.  
  1718. Room_Load_Permutation is a list whose first element is the initial room that is started at
  1719.  
  1720. All subsequent entries are transitions (Actor class objects with transition != False)
  1721.  
  1722.  
  1723. Room_List is a list of all available Rooms
  1724.  
  1725.  
  1726. This function returns what Room you would be in after entering every transition listed in
  1727. the permutation, assuming that you start in the initial room
  1728.  
  1729. """
  1730.  
  1731. if type(Room_Load_Permutation[0]) != Room:
  1732. print("ERROR: no initial room in permutation (Current_Room() function error message)")
  1733.  
  1734. current_room = Room_Load_Permutation[0]
  1735.  
  1736. if len(Room_Load_Permutation) > 1:
  1737.  
  1738. for transition in Room_Load_Permutation[1:len(Room_Load_Permutation)]:
  1739.  
  1740. current_room = New_Room(current_room, transition, Room_List)
  1741.  
  1742. return current_room
  1743.  
  1744.  
  1745. def Room_Order_List(Room_Load_Permutation, Room_List):
  1746.  
  1747. """
  1748.  
  1749. Room_Load_Permutation is a list whose first element is the initial room that is started at
  1750.  
  1751. All subsequent entries are transitions (Actor class objects with transition != False)
  1752.  
  1753.  
  1754. Room_List is a list of all available Rooms
  1755.  
  1756.  
  1757. This function returns a list of what Room you would be in at each step of
  1758. entering transitions
  1759.  
  1760. """
  1761.  
  1762. if type(Room_Load_Permutation[0]) != Room:
  1763. print("ERROR: no initial room in permutation (Get_Room_Load_List() function error message)")
  1764.  
  1765. room_order_list = []
  1766.  
  1767. for i in range(0, len(Room_Load_Permutation)):
  1768.  
  1769. current_room = Current_Room(Room_Load_Permutation[0:i+1], Room_List)
  1770.  
  1771. room_order_list.append(current_room)
  1772.  
  1773. return room_order_list
  1774.  
  1775.  
  1776. def Generate_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count):
  1777.  
  1778. """
  1779.  
  1780. TODO: Debug this function... try calling: Generate_Room_Load_Permutations(Room0, Room_List, 1)
  1781.  
  1782.  
  1783. This function seems to run for now, but it is untested for when we have multiple planes
  1784. I will test this once I do Deku Palace input
  1785.  
  1786. """
  1787.  
  1788. """
  1789.  
  1790. This function takes as input the initial room (Initial_Room) that the scene was loaded in
  1791. the list of all Rooms we want to consider visiting (Room_List), and Max_Transition_Count
  1792. which is the maximum number of times we want to allow ourselves to load a new room
  1793.  
  1794. This function returns a list of all permutations of ways to enter new rooms after starting
  1795. from the initial room (while limiting the number of room loads we do to be exactly Max_Transition_Count)
  1796. where each permutation is a list in the form [Initial_Room, Transition1, Transition2, Transition3, ..., TransitionX]
  1797. for X = Max_Transition_Count (so to get all permutations for X <= Max_Transition_Count, just
  1798. use a for loop and call this function in each iteration of the foor loop and concatenate the lists)
  1799.  
  1800. """
  1801.  
  1802. if Max_Transition_Count == 0:
  1803.  
  1804. new_permutation_list = [[Initial_Room]]
  1805.  
  1806. return new_permutation_list
  1807.  
  1808.  
  1809. else:
  1810.  
  1811. new_permutation_list = []
  1812. permutation_list = Generate_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count - 1)
  1813.  
  1814. for permutation in permutation_list:
  1815. for room in Neighbors(Current_Room(permutation, Room_List), Room_List):
  1816. for transition in Shared_Transitions(Current_Room(permutation, Room_List), room):
  1817. new_permutation = copy(permutation)
  1818. new_permutation.append(transition)
  1819. #permutation_list.append(new_permutation)
  1820. new_permutation_list.append(new_permutation)
  1821.  
  1822. return new_permutation_list
  1823.  
  1824.  
  1825. def Generate_All_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count):
  1826.  
  1827. """
  1828.  
  1829. This function returns all permutations of ways to load a room starting from the initial room
  1830. where the number of room loads is <= Max_Transition_Count
  1831.  
  1832. """
  1833.  
  1834. permutation_list = []
  1835.  
  1836. for N in range(Max_Transition_Count):
  1837.  
  1838. new_permutation_list = Generate_Room_Load_Permutations(Initial_Room, Room_List, N)
  1839. permutation_list = permutation_list + new_permutation_list
  1840.  
  1841. return permutation_list
  1842.  
  1843.  
  1844. def Generate_Almost_All_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count):
  1845.  
  1846. """
  1847.  
  1848. This function returns all permutations of ways to load a room starting from the initial room
  1849. where the number of room loads is <= Max_Transition_Count
  1850.  
  1851. this will always output a list with length at least 2, which is why it is different
  1852. from Generate_All_Room_Load_Permutations
  1853.  
  1854. """
  1855.  
  1856. permutation_list = []
  1857.  
  1858. for N in range(1, Max_Transition_Count):
  1859.  
  1860. new_permutation_list = Generate_Room_Load_Permutations(Initial_Room, Room_List, N)
  1861. permutation_list = permutation_list + new_permutation_list
  1862.  
  1863. return permutation_list
  1864.  
  1865.  
  1866. def Generate_All_Room_Order_Lists(Initial_Room, Room_List, Max_Transition_Count):
  1867.  
  1868. """
  1869.  
  1870. This function returns all permutations of ways to traverse through rooms, starting
  1871. from the initial room where the number of room loads is <= Max_Transition_Count
  1872.  
  1873. The distinction between this and Generate_All_Room_Load_Permutations is that
  1874. this will, instead of listing transitions, list the Room you're currently in
  1875. at each step
  1876.  
  1877. """
  1878.  
  1879. room_order_permutation_list = []
  1880.  
  1881. room_load_permutation_list = Generate_All_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count)
  1882.  
  1883.  
  1884. iteration_count = 0
  1885. for room_load_permutation in room_load_permutation_list:
  1886.  
  1887. print("Generate_All_Room_Order_Lists: %d out of %d" %(iteration_count, len(room_load_permutation_list)))
  1888. iteration_count += 1
  1889.  
  1890. room_order_list = Room_Order_List(room_load_permutation, Room_List)
  1891.  
  1892. room_order_permutation_list.append(room_order_list)
  1893.  
  1894. return room_order_permutation_list
  1895.  
  1896.  
  1897. def Generate_Allocation_Permutations(allocation_list):
  1898.  
  1899. """
  1900.  
  1901. Whatever, I'm just hardcoding a list of all of the actor names I want to allow
  1902. and then using itertools to make a list of all of the permutations
  1903.  
  1904. """
  1905.  
  1906. """
  1907.  
  1908. TODO: Finish this function, also generalize it in the future
  1909.  
  1910. """
  1911.  
  1912. """
  1913.  
  1914. THIS FUNCTION IS SIMPLIFIED AT THE MOMENT AND COULD BE IMPROVED TO GENERATE
  1915. EVEN MORE POSSIBLE PERMUTATIONS
  1916.  
  1917. allocation_list is a list of strings of things to allocate
  1918.  
  1919. for example:
  1920.  
  1921. allocation_list = [
  1922. 'Nothing',
  1923. 'Bomb',
  1924. 'Smoke',
  1925. 'Arrow',
  1926. 'Hookshot',
  1927. 'Charged Spin Attack',
  1928. 'Chu',
  1929. 'Zora Fins',
  1930. 'Fish',
  1931. 'Bugs'
  1932. ]
  1933.  
  1934. """
  1935.  
  1936. allocation_permutation_list = []
  1937.  
  1938.  
  1939. for i in range(len(allocation_list) + 1):
  1940.  
  1941. print("Generate_Allocation_Permutations: %d out of %d" %(i, len(allocation_list)))
  1942.  
  1943.  
  1944. Permutations = list(itertools.permutations(allocation_list, i))
  1945.  
  1946. allocation_permutation_list = allocation_permutation_list + Permutations
  1947.  
  1948. return allocation_permutation_list
  1949.  
  1950.  
  1951. def Clear_Instances(actor_id, room):
  1952.  
  1953. """
  1954.  
  1955. This function takes an actor_id and room as input and sets actor.cleared = True
  1956. for all actors with actor.id == actor_id in room
  1957.  
  1958. Call this before loading the scene or anything if you want some specific
  1959. actor cleared already. For example, I'd call Clear_Instances('015B', Room1)
  1960. to clear all of the bad bats in Beneath the Graveyard
  1961.  
  1962. """
  1963.  
  1964. for actor in room.priority_queue:
  1965.  
  1966. if actor.Id == actor_id and actor.clearable == True:
  1967.  
  1968. actor.cleared = True
  1969.  
  1970.  
  1971. def Clear_Instance(actor, room):
  1972.  
  1973. """
  1974.  
  1975. This function takes a specific actor in a room as input and sets
  1976. actor.cleared = True
  1977.  
  1978. """
  1979.  
  1980. if actor.clearable == True:
  1981.  
  1982. actor.cleared = True
  1983.  
  1984.  
  1985. def Generate_Deallocation_Combinations(room):
  1986.  
  1987. """
  1988. ##### Note: we actually get combinations instead of permutations because
  1989. the order in which we deallocate actors doesn't matter
  1990.  
  1991. This function returns a list of combinations (stored as tuples of Actors)
  1992.  
  1993.  
  1994.  
  1995. Some things this (or maybe some other) function needs to account for:
  1996.  
  1997. if any rupee from a rupee cluster is deallocated in a deallocation step,
  1998. then clear the rupee cluster actor instance (00E8) [note that there is
  1999. at most one rupee cluster instance in every room in the game, so there is
  2000. no need to check which cluster the rupees are associated with]
  2001.  
  2002. if all bad bats are deallocated on the same deallocation step, then they
  2003. must all be cleared... actually, stronger: if all Category 5 actors with
  2004. the same Id in a given room are deallocated on the same deallocation step,
  2005. then clear all instances... actually this isn't good enough (need to add
  2006. this into the input I believe or just treat bad bats as a special case)
  2007.  
  2008.  
  2009. """
  2010.  
  2011. deallocation_list = []
  2012.  
  2013. for actor in room.priority_queue:
  2014.  
  2015. if actor.cleared == False and actor.unloadable == True:
  2016.  
  2017. deallocation_list.append(actor)
  2018.  
  2019. ##### Now we have a list of all actors in room that we have the option of deallocationg
  2020.  
  2021. ##### Now want want to generate a list of permutations
  2022. ########## ACTUALLY, order doesn't matter for deallocation, so all combinations suffices
  2023.  
  2024. combination_list = []
  2025.  
  2026. for i in range(len(deallocation_list) + 1):
  2027.  
  2028. Combinations = list(itertools.combinations(deallocation_list, i))
  2029.  
  2030. combination_list = combination_list + Combinations
  2031.  
  2032. return combination_list
  2033.  
  2034.  
  2035.  
  2036.  
  2037. def Build_Room_Deallocation_Combination_Graph(room_order_list):
  2038.  
  2039.  
  2040. """
  2041.  
  2042. This function takes a room_order_list as input (that is, a list in the form
  2043. [initial_room, Room1, Room2, Room3, ..., RoomN] which describes the order we
  2044. visit rooms in (note that Roomi could be equal to Roomj even for i =/= j)) and
  2045. returns a dictionary where the keys are vertices whose values are lists of the
  2046. other vertices that they are connected to. Each vertex represents a deallocation
  2047. combination for the room that it corresponds to.
  2048.  
  2049. If the edges are directed, then this can be viewed as a multitree with some
  2050. dummy root vertex and then each generation corresponds to a Room.
  2051.  
  2052. """
  2053.  
  2054. room_count = 0
  2055.  
  2056. #### Encode a dummy root node to make finding paths easier
  2057. graph = {('root', room_count - 1) : []}
  2058.  
  2059.  
  2060. iteration_count = 0
  2061. ### for all rooms except for the last one
  2062. for room in room_order_list[0:len(room_order_list)-1]:
  2063.  
  2064. print("Build_Room_Deallocation_Combination_Graph: %d out of %d" %(iteration_count, len(room_order_list) - 1))
  2065. iteration_count += 1
  2066.  
  2067. combination_list = Generate_Deallocation_Combinations(room)
  2068.  
  2069. for combination in combination_list:
  2070.  
  2071. for key in graph.keys():
  2072.  
  2073. ### If the key is from the previous generation, then append every combination to its list
  2074. if key[1] == room_count - 1:
  2075.  
  2076. graph[key].append(combination)
  2077.  
  2078. graph[(combination, room_count)] = []
  2079.  
  2080. room_count += 1
  2081.  
  2082. return graph
  2083.  
  2084.  
  2085. def Find_Leaves(graph):
  2086.  
  2087. """
  2088.  
  2089. This function takes a graph (really a dictionary) created by Build_Room_Deallocation_Combination_Graph()
  2090. and returns a list of all of its leaves
  2091.  
  2092. """
  2093.  
  2094. leaf_list = []
  2095.  
  2096. for key in graph:
  2097. # only leaves will point to empty lists
  2098. if graph[key] == []:
  2099. leaf_list.append(key)
  2100.  
  2101. return leaf_list
  2102.  
  2103.  
  2104. def Find_All_Paths(graph, start, end, path=[]):
  2105.  
  2106. """
  2107.  
  2108. This function takes a graph (really a dictionary) and start and end vertices
  2109. as input and returns a list of all paths from start to end
  2110.  
  2111. TODO: maybe don't rely on hardcoding what the root's key is and instead write
  2112. a function to find it (though hardcode is prob faster if you don't make mistakes)
  2113.  
  2114. I will use this to find all paths from ('root', -1) [note that I am hardcoding
  2115. this instead of just finding a root without any parent] to a given lead, and
  2116. I will do this for all leafs (which I can get by doing Find_Leaves(graph))
  2117.  
  2118. """
  2119.  
  2120.  
  2121. path = path + [start]
  2122. if start == end:
  2123. return [path]
  2124. if not (start in graph):
  2125. return []
  2126. paths = []
  2127. for vertex in graph[start]:
  2128. if vertex not in path:
  2129. newpaths = Find_All_Paths(graph, vertex, end, path)
  2130. for newpath in newpaths:
  2131. paths.append(newpath)
  2132. return paths
  2133.  
  2134.  
  2135. def Find_All_Deallocation_Combination_Paths(graph):
  2136.  
  2137. """
  2138.  
  2139. TODO: Note that I hardcode what the key of the root vertex is: ('root', -1)
  2140.  
  2141. This returns a list of all (n-1)-permutations of deallocation combinations
  2142. for a given room_order_list (where we assume there are n rooms we travel to
  2143. including the initial room). This gives us the thing we called D1
  2144.  
  2145. """
  2146.  
  2147. all_deallocation_combination_paths = []
  2148.  
  2149. leaf_list = Find_Leaves(graph)
  2150.  
  2151. iteration_count = 0
  2152. for leaf in leaf_list:
  2153.  
  2154. print("Find_All_Deallocation_Combination_Paths: %d out of %d" %(iteration_count, len(leaf_list)))
  2155. iteration_count += 1
  2156.  
  2157. # I hardcode the root key to be ('root', -1)
  2158. path_to_leaf = Find_All_Paths(graph, ('root', -1), leaf)
  2159.  
  2160. all_deallocation_combination_paths = all_deallocation_combination_paths + path_to_leaf
  2161.  
  2162.  
  2163. ##### Since every key is a tuple in the form (combination, number), get rid of number part
  2164. for path in all_deallocation_combination_paths:
  2165. for vertex in path:
  2166. path[path.index(vertex)] = vertex[0]
  2167.  
  2168. return all_deallocation_combination_paths
  2169.  
  2170.  
  2171.  
  2172.  
  2173. def Generate_Action_Permutations(room_order_list, allocation_list):
  2174.  
  2175. """
  2176.  
  2177. THIS IS THE FUNCTION THAT FINALLY GIVES US ALL OF THE PERMUTATIONS OF THINGS
  2178. TO DO FOR A GIVEN room_order_list and the allocation_list.
  2179.  
  2180.  
  2181.  
  2182. WE WILL RUN THIS FUNCTION ON EVERY PERMUTATION OF ROOM ORDER LISTS USING
  2183. Generate_All_Room_Order_Lists(Initial_Room, Room_List, Max_Transition_Count)
  2184.  
  2185.  
  2186. ONCE WE DO THAT WE WILL HAVE EVERY SINGLE PERMUTATION THAT WE WANT TO TEST
  2187.  
  2188. """
  2189.  
  2190. allocation_permutations = Generate_Allocation_Permutations(allocation_list)
  2191.  
  2192. ##### Now we want all (n-1)-permutations of allocation permutations
  2193. A1 = list(itertools.permutations(allocation_permutations, len(room_order_list) - 1))
  2194.  
  2195. #### deallocation combination graph
  2196. graph = Build_Room_Deallocation_Combination_Graph(room_order_list)
  2197.  
  2198. D1 = Find_All_Deallocation_Combination_Paths(graph)
  2199.  
  2200. ###########################################################################
  2201.  
  2202. # create output list o
  2203. o = []
  2204. for i in range(len(A1)):
  2205.  
  2206. print("Generate_Action_Permutations: %d out of %d" %(i, len(A1)))
  2207.  
  2208. for j in range(len(D1)):
  2209. for b in range(2**(len(room_order_list) - 1)):
  2210. # create new empty list p
  2211. p = []
  2212. for k in range(len(room_order_list) - 1):
  2213. p.append(room_order_list[k])
  2214.  
  2215. if bin(b)[2:].zfill(len(room_order_list)-1) == 1:
  2216.  
  2217. # add each element of A1[i][k] to p
  2218. for element in A1[i][k]:
  2219. p.append(element)
  2220. # add each element of D1[j][k] to p
  2221. for element in D1[j][k]:
  2222. p.append(element)
  2223.  
  2224. elif bin(b)[2:].zfill(len(room_order_list)-1) == 0:
  2225.  
  2226. # add each element of D1[j][k] to p
  2227. for element in D1[j][k]:
  2228. p.append(element)
  2229. # add each element of A1[i][k] to p
  2230. for element in A1[i][k]:
  2231. p.append(element)
  2232.  
  2233. # Add the last room to p
  2234. p.append(room_order_list[len(room_order_list)-1])
  2235. # append p to o
  2236. o = o + p
  2237.  
  2238. return o
  2239.  
  2240.  
  2241.  
  2242. def Generate_Heap_Permutations(Initial_Room, Room_List, Max_Transition_Count, allocation_list):
  2243.  
  2244. """
  2245.  
  2246. This function takes the initial room, the Room List, the Maximum Number of Transitions
  2247. that we want to allow, and the allocation list as input and returns every permutation
  2248. for heap manip setups to try (possibilities currently mostly limited by allocation_list)
  2249.  
  2250. WE WILL USE THIS FUNCTION IN THE HEAP MANIP SOLVER
  2251.  
  2252. """
  2253.  
  2254. heap_permutations = []
  2255.  
  2256. All_Room_Order_Lists = Generate_All_Room_Order_Lists(Initial_Room, Room_List, Max_Transition_Count)
  2257.  
  2258. iteration_count= 0
  2259. for room_order_list in All_Room_Order_Lists:
  2260.  
  2261. print("Iteration %d out of %d" %(iteration_count, len(All_Room_Order_Lists)))
  2262.  
  2263. action_permutations = Generate_Action_Permutations(room_order_list, allocation_list)
  2264.  
  2265. heap_permutations = heap_permutations + action_permutations
  2266.  
  2267. iteration_count += 1
  2268.  
  2269.  
  2270. print("HEAP PERMUTATION GENERATION COMPLETE")
  2271.  
  2272. return heap_permutations
  2273.  
  2274.  
  2275.  
  2276. ###############################################################################
  2277. ###############################################################################
  2278. ###############################################################################
  2279. ###############################################################################
  2280. ###############################################################################
  2281. ###############################################################################
  2282. ###############################################################################
  2283.  
  2284. def Actor_Is_In_Heap(Heap, actor):
  2285.  
  2286. """
  2287.  
  2288. actor is the Actor that we want to check for
  2289.  
  2290. This function will return True if this Actor is in the Heap and False otherwise
  2291.  
  2292. """
  2293.  
  2294. actor_is_in_heap = False
  2295.  
  2296. for entry in Heap:
  2297.  
  2298. if type(entry) == Actor and entry == actor:
  2299.  
  2300. actor_is_in_heap = True
  2301.  
  2302. return actor_is_in_heap
  2303.  
  2304. def Actor_Is_In_Room(room, actor):
  2305.  
  2306. """
  2307.  
  2308. actor is the Actor that we want to check for
  2309.  
  2310. This function will return True if this Actor is in the room and False otherwise
  2311.  
  2312. """
  2313.  
  2314. actor_is_in_room = False
  2315.  
  2316. for entry in room.priority_queue:
  2317.  
  2318. if type(entry) == Actor and entry == actor:
  2319.  
  2320. actor_is_in_room = True
  2321.  
  2322. return actor_is_in_room
  2323.  
  2324.  
  2325.  
  2326. def Bomb_And_Smoke_Superslide(Heap, Room_Number, Overlay_dict):
  2327.  
  2328. """
  2329.  
  2330. This function allocates a bomb, then allocates smoke (this happens when the bomb explodes)
  2331.  
  2332. """
  2333.  
  2334. Bomb = Actor(name='Bomb', Id='0009', size=516, category=0, overlay_type='B', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  2335.  
  2336. Allocate(Heap, Bomb, Overlay_dict)
  2337.  
  2338. Smoke = Actor(name='Smoke', Id='00A2', size=11908, category=0, overlay_type='A', unloadable=True, address=0, room_number=Room_Number, priority=0, from_spawner=False, transition=False, clearable=False, cleared=False)
  2339.  
  2340. Allocate(Heap, Smoke, Overlay_dict)
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346. def Copy_Room_List(Room_List):
  2347.  
  2348. """
  2349.  
  2350. This function takes a list of all Rooms, Room_List, as input
  2351. and returns a list of copies of all of the Rooms in Room_List
  2352.  
  2353. """
  2354.  
  2355. ##### First we want a list of all shared entries between the Room priority queues
  2356.  
  2357. shared_actor_list = []
  2358.  
  2359. for room1 in Room_List:
  2360. for room2 in Room_List:
  2361.  
  2362. if room2 != room1:
  2363.  
  2364. for actor1 in room1.priority_queue:
  2365. for actor2 in room2.priority_queue:
  2366. if (actor1 == actor2) and (actor1 not in shared_actor_list):
  2367.  
  2368. shared_actor_list.append(actor1)
  2369.  
  2370. ##### Now make a list of copies of each entry of the above list
  2371.  
  2372. shared_actor_copy_list = []
  2373. for actor in shared_actor_list:
  2374. shared_actor_copy_list.append(copy(actor))
  2375.  
  2376. Room_List_Copy = []
  2377.  
  2378. for room in Room_List:
  2379.  
  2380. priority_queue_copy = []
  2381.  
  2382. for actor in room.priority_queue:
  2383.  
  2384. if actor not in shared_actor_list:
  2385.  
  2386. priority_queue_copy.append(copy(actor))
  2387.  
  2388. elif actor in shared_actor_list:
  2389. append_count = 0
  2390. for actor2 in shared_actor_copy_list:
  2391.  
  2392. # If all attributes of the actor and the copy are the same, then assume they are copies of each other
  2393. if actor2.name == actor.name and actor2.Id == actor.Id and actor2.size == actor.size and actor2.category == actor.category and actor2.overlay_type == actor.overlay_type and actor2.unloadable == actor.unloadable and actor2.address == actor.address and actor2.room_number == actor.room_number and actor2.priority == actor.priority and actor2.from_spawner == actor.from_spawner and actor2.transition == actor.transition and actor2.clearable == actor.clearable and actor2.cleared == actor.cleared:
  2394. # append the copy
  2395. priority_queue_copy.append(actor2)
  2396. append_count += 1
  2397.  
  2398. if append_count > 1:
  2399. print("ERROR: There were two or more copies of the same Actor in shared_actor_copy_list (Copy_Room_List() error message)")
  2400.  
  2401.  
  2402. room_copy = Room(number=room.number, priority_queue=priority_queue_copy, clock_exists=room.clock_exists, clock_priority=room.clock_priority)
  2403.  
  2404. Room_List_Copy.append(room_copy)
  2405.  
  2406. return Room_List_Copy
  2407.  
  2408.  
  2409.  
  2410.  
  2411. def Main_Actor_Attributes_Match(actor1, actor2):
  2412.  
  2413. """
  2414.  
  2415. This function returns True is the two Actors taken as input have the same
  2416. values for all of their main attributes and False otherwise
  2417.  
  2418. the main attributes do not include things like "address" and such that can
  2419. change as the state updates
  2420.  
  2421. """
  2422.  
  2423. main_actor_attributes_match = False
  2424.  
  2425. if actor1.name == actor2.name and actor1.Id == actor2.Id and actor1.size == actor2.size and actor1.category == actor2.category and actor1.overlay_type == actor2.overlay_type and actor1.unloadable == actor2.unloadable and actor1.room_number is actor2.room_number and actor1.priority is actor2.priority and actor1.from_spawner == actor2.from_spawner and actor1.transition == actor2.transition and actor1.clearable == actor2.clearable:
  2426. main_actor_attributes_match = True
  2427.  
  2428. return main_actor_attributes_match
  2429.  
  2430.  
  2431. def Main_Overlay_Attributes_Match(overlay1, overlay2):
  2432.  
  2433. main_overlay_attributes_match = False
  2434.  
  2435. if overlay1.Id == overlay2.Id and overlay1.size == overlay2.size:
  2436. main_overlay_attributes_match = True
  2437.  
  2438. return main_overlay_attributes_match
  2439.  
  2440.  
  2441. def Copy_Overlay_Dict(Overlay_Dict):
  2442.  
  2443. overlay_dict_copy = {}
  2444.  
  2445. for key in Overlay_Dict:
  2446. overlay_dict_copy[key] = copy(Overlay_Dict[key])
  2447.  
  2448. return overlay_dict_copy
  2449.  
  2450.  
  2451. def Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy):
  2452.  
  2453. """
  2454.  
  2455. This function takes the Heap as input and returns a copy of the Heap where
  2456. every actor copy in the Heap copy is the same class instance as each corresponding
  2457. actor in the room list copy priority queues (same for Overlay_Dict_Copy)
  2458.  
  2459. """
  2460.  
  2461. Heap_Copy = []
  2462.  
  2463. for entry in Heap:
  2464.  
  2465. entry_allocated = False
  2466. not_allocated_count = 0
  2467. while entry_allocated is False:
  2468.  
  2469. if not_allocated_count > 4:
  2470. print("UHHHHHHHHHHHHHHHHHHHHHHHH (Copy_Heap() Error Message)")
  2471.  
  2472. if type(entry) == Node:
  2473.  
  2474. Heap_Copy.append(copy(entry))
  2475. entry_allocated = True
  2476.  
  2477. elif type(entry) == Overlay:
  2478.  
  2479. for key in Overlay_Dict_Copy:
  2480. if Main_Overlay_Attributes_Match(Overlay_Dict_Copy[key], entry) == True:
  2481. Heap_Copy.append(Overlay_Dict_Copy[key])
  2482. entry_allocated = True
  2483.  
  2484. elif type(entry) == Actor:
  2485.  
  2486. allocated_count = 0
  2487. for room in Room_List_Copy:
  2488.  
  2489. if entry_allocated == True:
  2490. break
  2491.  
  2492. for actor in room.priority_queue:
  2493.  
  2494. if allocated_count > 1:
  2495. print("ERROR: tried to allocate multiple copies (Copy_Heap() Error Message)")
  2496.  
  2497. if Main_Actor_Attributes_Match(entry, actor) == True:
  2498. Heap_Copy.append(actor)
  2499. allocated_count += 1
  2500. entry_allocated = True
  2501. break
  2502.  
  2503. # If it isn't in any of the priority queues, then it must be something you spawned
  2504. if entry_allocated == False:
  2505. Heap_Copy.append(copy(entry))
  2506. entry_allocated = True
  2507.  
  2508. else:
  2509. print("ERROR: entry in Heap is not an Actor, Node, or Overlay (Copy_Heap() error message)")
  2510.  
  2511. not_allocated_count += 1
  2512. return Heap_Copy
  2513.  
  2514.  
  2515. def Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy):
  2516.  
  2517. """
  2518.  
  2519. This function takes the Grabbable_Dict as input and returns a copy of the it where
  2520. each transition in it is a the same Actor class instance copy as the ones used in
  2521. the priority queues of the Rooms in Room_List_Copy
  2522.  
  2523. """
  2524.  
  2525. grabbable_dict_copy = {}
  2526.  
  2527. for pot in Grabbable_Dict:
  2528.  
  2529. pot_in_dict = False
  2530.  
  2531.  
  2532. for room in Room_List_Copy:
  2533. if pot_in_dict == True:
  2534. break
  2535. for actor in room.priority_queue:
  2536. if Main_Actor_Attributes_Match(pot, actor) == True:
  2537.  
  2538. key = actor
  2539.  
  2540. for room1 in Room_List_Copy:
  2541. if pot_in_dict == True:
  2542. break
  2543. for actor1 in room1.priority_queue:
  2544.  
  2545. # Finding the transition
  2546. if Main_Actor_Attributes_Match(Grabbable_Dict[pot][1], actor1):
  2547.  
  2548. grabbable_dict_copy[key] = [Grabbable_Dict[pot][0], actor1]
  2549. pot_in_dict = True
  2550.  
  2551. return grabbable_dict_copy
  2552.  
  2553.  
  2554. def Find_Actor_Copy(actor, Room_List_Copy):
  2555.  
  2556. """
  2557.  
  2558. This function takes an Actor as input (actor) and a copy of the list of rooms
  2559. (Room_List_Copy) and returns the copy of the inputted actor that is found in
  2560. the priority queue of a Room in Room_List_Copy
  2561.  
  2562. """
  2563.  
  2564. actor_copy = None
  2565.  
  2566. copy_found = False
  2567. for room in Room_List_Copy:
  2568. if copy_found == True:
  2569. break
  2570. for actor1 in room.priority_queue:
  2571. if Main_Actor_Attributes_Match(actor1, actor):
  2572. actor_copy = actor1
  2573. copy_found = True
  2574. break
  2575.  
  2576. return actor_copy
  2577.  
  2578.  
  2579. """
  2580.  
  2581. TODO: Make the solver take the initial heap layout as input so that it is easy
  2582. to test successive heap manip setups in the future
  2583.  
  2584. DO NOT FORGET TO CLEAR ALL OF THE BAD BATS IF YOU THINK THAT THAT IS SOMETHING
  2585. THAT YOU WANT TO DO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2586.  
  2587. ALSO IGNORE THAT FUNCTION BELOW, COMPLETELY REWRITE FROM SCRATCH BUT MAYBE READ
  2588. IT FIRST TO SEE IF IT REMINDS YOU OF ANY IDEAS YOU HAD
  2589.  
  2590. """
  2591.  
  2592.  
  2593. def Randomized_Solver(Initial_Room, Room_List, Max_Transition_Count, allocation_list_dict, Grabbable_Dict, Overlay_Dict, filename, Offset_List, Initial_Heap):
  2594.  
  2595. """
  2596.  
  2597. This function does not currently account for the possibility that you might need to break
  2598. another pot in order to superslide off of a given pot. While this might not be strictly
  2599. true for the pot we currently use in deku palace, it would be good at add more information
  2600. to Grabbable_Dict to account for this
  2601.  
  2602. """
  2603.  
  2604. """
  2605.  
  2606. Okay, the Initial_Heap argument will not work as I initially intended because of things
  2607. like rupee clusters being cleared, etc. So if I want to test a Heap from an initial Heap
  2608. distribution, then I will have to hardcode it to perform the necessary steps to get to it each time
  2609.  
  2610. """
  2611.  
  2612. """
  2613.  
  2614. filename is the complete name (i.e. including the path) that we want to write to
  2615.  
  2616. This function will randomly choose solutions to test (it may have repeats)
  2617.  
  2618. Offset_List is a list of offsets that we want to check for. The grabbable object (e.g. a pot)
  2619. will be first when calculating the offset. So if doing chest SRM, we want
  2620. pot - chest = 0x160 or pot - chest = 0x1F0, so we want Offset_List = [0x160, 0x1F0]
  2621. We make this Offset_List by default
  2622.  
  2623. Grabbable_dict is a dictionary of the grabbable actors (such as pots) that
  2624. we want to attempt to use for superslide SRM where the keys are the grabbable
  2625. actors and the values are 3-bit strings where each bit means:
  2626.  
  2627. 100 : Possible to enter Plane with both Bomb and Smoke loaded
  2628. 010 : Possible to enter Plane with Smoke loaded, but no Bomb loaded
  2629. 001 : Possible to enter Plane with no Smoke loaded
  2630.  
  2631. """
  2632.  
  2633. angle_solution_count = 0
  2634. position_solution_count = 0
  2635. permutation_count = 0
  2636.  
  2637. ### Keep doing this forever (infinite loop so we keep trying new permutations)
  2638. while True:
  2639.  
  2640. all_room_load_lists = Generate_Almost_All_Room_Load_Permutations(Initial_Room, Room_List, Max_Transition_Count)
  2641.  
  2642. for room_load_list in all_room_load_lists:
  2643.  
  2644. if permutation_count%500 == 0:
  2645. print("%d Permutations Tested %d Angle Solutions %d Position Solutions" %(permutation_count, angle_solution_count, position_solution_count))
  2646. permutation_count += 1
  2647.  
  2648. Heap = copy(Initial_Heap)
  2649.  
  2650. ##### Initialize the actor addresses and other attributes each time
  2651.  
  2652. for room in Room_List:
  2653.  
  2654. for actor in room.priority_queue:
  2655.  
  2656. actor.address = 0
  2657. actor.cleared = False
  2658.  
  2659. ##### Clear all bad bats (optional, but I want to do this for beneath the graveyard)
  2660. Clear_Instances('015B', room)
  2661. ###################################################################
  2662.  
  2663. #####
  2664. ##### Perform seuqence of steps here if you want to initialize your heap to something
  2665. #####
  2666.  
  2667. # We will use this to collect things we do in the permutation to help output the solution
  2668. action_list = []
  2669.  
  2670. room_count = 0
  2671. # NOTE: the first "transition" is actually not a transition; it is the initial room
  2672. for transition in room_load_list[0:len(room_load_list)-1]:
  2673.  
  2674. room = Current_Room(room_load_list[0:room_count + 1], Room_List)
  2675.  
  2676. # If this is the Initial_Room AND the Heap is empty, then we want to load the scene
  2677. if (room_count is 0) and (len(Heap) == 2):
  2678.  
  2679. if room != Initial_Room:
  2680. print("ERROR: first entry in room_load_list is not Initial_Room (Randomnized_Solver() Error Message)")
  2681.  
  2682. Load_Scene(Heap, Initial_Room, Overlay_Dict)
  2683. action_list.append("Load Scene: Room %d" %(Initial_Room.number))
  2684.  
  2685. ##### NOW WE DO DEALLOCATION/ALLOCATION STEPS AFTER LOADING THE SCENE
  2686.  
  2687.  
  2688. """
  2689.  
  2690. Now randomly (with some chosen distribution) choose things to allocate
  2691. and/or things to deallocate (in your current room). Make it so that
  2692. you can only choose a specific action once. For example, if allocation_list
  2693. has ['bomb', 'bomb, 'bomb', 'fish'] in it, then make it so you can only use
  2694. fish once, but you can use bomb 3 times
  2695.  
  2696. Somehow try to encode that hookshot/charged spin are mutually exclusive
  2697. and that if either of them exist then they must be the last action
  2698.  
  2699. Allow yourself to deallocate things before allocating things even
  2700. though it might be impossible or slow in some cases
  2701.  
  2702. """
  2703.  
  2704. # Do a coinflip to decide between allocating or deallocating first
  2705. #decision_coin_flip = np.random.uniform(0,1)
  2706. ##### Deterministically do deallocation step first
  2707. decision_coin_flip = 0
  2708.  
  2709. # With probability 1/2, we allocate first and deallocate second
  2710. # if we allocate first, don't allow 'Charged Spin Attack'
  2711. if decision_coin_flip > .5:
  2712.  
  2713. explosive_count = 0
  2714. droppable_count = 0
  2715.  
  2716. ##### ALLOCATION
  2717. for action in allocation_list_dict[room.number]:
  2718.  
  2719. # whether or not we add an action is based off of this
  2720. coin_flip = np.random.uniform(0,1)
  2721.  
  2722. if action == 'Smoke' and coin_flip > .5:
  2723.  
  2724. Allocate_Smoke(Heap, room.number, Overlay_Dict)
  2725. action_list.append("Allocate: Smoke")
  2726.  
  2727. elif action == 'Square Sign' and coin_flip > .5:
  2728.  
  2729. Allocate_Square_Sign(Heap, room.number, Overlay_Dict)
  2730. action_list.append("Allocate: Square Sign")
  2731.  
  2732. elif action == 'Chu' and coin_flip > .5 and explosive_count < 3:
  2733.  
  2734. Allocate_Chu(Heap, room.number, Overlay_Dict)
  2735. action_list.append("Allocate: Chu")
  2736. explosive_count += 1
  2737.  
  2738. elif action == 'Arrow' and coin_flip > .5:
  2739.  
  2740. Allocate_Arrow(Heap, room.number, Overlay_Dict)
  2741. action_list.append("Allocate: Arrow")
  2742.  
  2743. elif action == 'Bomb' and coin_flip > .5 and explosive_count < 3:
  2744.  
  2745. Allocate_Bomb(Heap, room.number, Overlay_Dict)
  2746. action_list.append("Allocate: Bomb")
  2747. explosive_count += 1
  2748.  
  2749. elif action == 'Zora Fins' and coin_flip > .5:
  2750.  
  2751. Allocate_Zora_Fins(Heap, room.number, Overlay_Dict)
  2752. action_list.append("Allocate: Zora Fins")
  2753.  
  2754. elif action == 'Fish' and coin_flip > .5 and droppable_count < 2:
  2755.  
  2756. Allocate_Fish(Heap, room.number, Overlay_Dict)
  2757. action_list.append("Allocate: Fish")
  2758. droppable_count += 1
  2759.  
  2760. elif action == 'Bugs' and coin_flip > .5 and droppable_count < 2:
  2761.  
  2762. Allocate_Bugs(Heap, room.number, Overlay_Dict)
  2763. action_list.append("Allocate: Bugs")
  2764. droppable_count += 1
  2765.  
  2766. elif action == 'Hookshot' and coin_flip > .5:
  2767.  
  2768. Allocate_Hookshot(Heap, room.number, Overlay_Dict)
  2769. action_list.append("Allocate: Hookshot")
  2770.  
  2771. elif action == 'Gold Skulltula' and coin_flip > .5:
  2772.  
  2773. projectile_coin_flip = np.random.uniform(0,1)
  2774.  
  2775. if projectile_coin_flip > .5:
  2776. Allocate_Gold_Skulltula_With_Hookshot(Heap, room.number, Overlay_Dict)
  2777. action_list.append("Allocate: Gold Skulltula with Hookshot (hit painting)")
  2778.  
  2779. elif projectile_coin_flip <= .5:
  2780. Allocate_Gold_Skulltula_With_Arrow(Heap, room.number, Overlay_Dict)
  2781. action_list.append("Allocate: Gold Skulltula with Arrow (hit painting)")
  2782.  
  2783. ### We don't include 'Charged Spin Attack' in this
  2784.  
  2785. ##### DEALLOCATION
  2786. for actor in room.priority_queue:
  2787.  
  2788. # whether or not we deallocate an actor is based off of this
  2789. coin_flip = np.random.uniform(0,1)
  2790.  
  2791. ##### HARDCODE TO NOT ALLOW GOLD SKULLTULA OR SPIDER WEBS DEALLOCATE BECAUSE FASTER FOR 100%
  2792. if actor.unloadable == True and Actor_Is_In_Heap(Heap, actor) == True and coin_flip > .5 and actor.Id != '0050' and actor.Id != '01F4' and actor.Id != '0125':
  2793.  
  2794.  
  2795. if actor.Id == '00E8' or actor.name == 'Collectible (Rupee from Rupee Cluster)':
  2796.  
  2797. Deallocate(Heap, actor, Overlay_Dict)
  2798. # There is at most one rupee cluster per room, so this is fine to clear it
  2799. Clear_Instances('00E8', room)
  2800. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2801.  
  2802. # THESE PRIORITIES ARE HARDCODED FOR ROOM 3 OF OCEANSIDE!!!!!!!
  2803. elif actor.Id == '01E7' and (actor.priority == 0 or actor.priority == 1 or actor.priority == 2):
  2804.  
  2805. table_bonk_deallocation_count = 0
  2806. for entry in Heap:
  2807. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 0:
  2808. Deallocate(Heap, entry, Overlay_Dict)
  2809. table_bonk_deallocation_count += 1
  2810.  
  2811. for entry in Heap:
  2812. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 1:
  2813. Deallocate(Heap, entry, Overlay_Dict)
  2814. table_bonk_deallocation_count += 1
  2815.  
  2816. for entry in Heap:
  2817. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 2:
  2818. Deallocate(Heap, entry, Overlay_Dict)
  2819. table_bonk_deallocation_count += 1
  2820.  
  2821. if table_bonk_deallocation_count != 3:
  2822. print("ERROR: table_bonk_deallocation_count is not 3 (Randomized_Solver() error)")
  2823.  
  2824. action_list.append("Deallocate: " + actor.name + " (Priority 0, 1, and 2) [Bonk Oceanside Table]")
  2825.  
  2826.  
  2827. # if the actor is clearable AND isn't a bad bat, then clear it when deallocating it if it isn't already cleared
  2828. elif actor.clearable == True and actor.cleared == False and actor.Id != '015B':
  2829.  
  2830. Deallocate(Heap, actor, Overlay_Dict)
  2831. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2832. # CLEAR THE ACTOR
  2833. Clear_Instance(actor, room)
  2834.  
  2835. else:
  2836.  
  2837. Deallocate(Heap, actor, Overlay_Dict)
  2838. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2839.  
  2840.  
  2841. # With probability 1/2, we deallocate first and allocate second
  2842. elif decision_coin_flip <= .5:
  2843.  
  2844. explosive_count = 0
  2845. droppable_count = 0
  2846. hookshot_exists = False
  2847.  
  2848. ##### DEALLOCATION
  2849. for actor in room.priority_queue:
  2850.  
  2851. # whether or not we deallocate an actor is based off of this
  2852. coin_flip = np.random.uniform(0,1)
  2853.  
  2854. ##### HARDCODE TO NOT ALLOW GOLD SKULLTULA OR SPIDER WEBS DEALLOCATE BECAUSE FASTER FOR 100%
  2855. if actor.unloadable == True and Actor_Is_In_Heap(Heap, actor) == True and coin_flip > .5 and actor.Id != '0050' and actor.Id != '01F4' and actor.Id != '0125':
  2856.  
  2857.  
  2858. if actor.Id == '00E8' or actor.name == 'Collectible (Rupee from Rupee Cluster)':
  2859.  
  2860. Deallocate(Heap, actor, Overlay_Dict)
  2861. # There is at most one rupee cluster per room, so this is fine to clear it
  2862. Clear_Instances('00E8', room)
  2863. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2864.  
  2865. # THESE PRIORITIES ARE HARDCODED FOR ROOM 3 OF OCEANSIDE!!!!!!!
  2866. elif actor.Id == '01E7' and (actor.priority == 0 or actor.priority == 1 or actor.priority == 2):
  2867.  
  2868. table_bonk_deallocation_count = 0
  2869. for entry in Heap:
  2870. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 0:
  2871. Deallocate(Heap, entry, Overlay_Dict)
  2872. table_bonk_deallocation_count += 1
  2873.  
  2874. for entry in Heap:
  2875. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 1:
  2876. Deallocate(Heap, entry, Overlay_Dict)
  2877. table_bonk_deallocation_count += 1
  2878.  
  2879. for entry in Heap:
  2880. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 2:
  2881. Deallocate(Heap, entry, Overlay_Dict)
  2882. table_bonk_deallocation_count += 1
  2883.  
  2884. if table_bonk_deallocation_count != 3:
  2885. print("ERROR: table_bonk_deallocation_count is not 3 (Randomized_Solver() error)")
  2886.  
  2887. action_list.append("Deallocate: " + actor.name + " (Priority 0, 1, and 2) [Bonk Oceanside Table]")
  2888.  
  2889.  
  2890. # if the actor is clearable AND isn't a bad bat, then clear it when deallocating it if it isn't already cleared
  2891. elif actor.clearable == True and actor.cleared == False and actor.Id != '015B':
  2892.  
  2893. Deallocate(Heap, actor, Overlay_Dict)
  2894. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2895. # CLEAR THE ACTOR
  2896. Clear_Instance(actor, room)
  2897.  
  2898. else:
  2899.  
  2900. Deallocate(Heap, actor, Overlay_Dict)
  2901. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  2902.  
  2903.  
  2904. ##### ALLOCATION
  2905. for action in allocation_list_dict[room.number]:
  2906.  
  2907. # whether or not we add an action is based off of this
  2908. coin_flip = np.random.uniform(0,1)
  2909.  
  2910. if action == 'Smoke' and coin_flip > .5:
  2911.  
  2912. Allocate_Smoke(Heap, room.number, Overlay_Dict)
  2913. action_list.append("Allocate: Smoke")
  2914.  
  2915. elif action == 'Square Sign' and coin_flip > .5:
  2916.  
  2917. Allocate_Square_Sign(Heap, room.number, Overlay_Dict)
  2918. action_list.append("Allocate: Square Sign")
  2919.  
  2920. elif action == 'Chu' and coin_flip > .5 and explosive_count < 3:
  2921.  
  2922. Allocate_Chu(Heap, room.number, Overlay_Dict)
  2923. action_list.append("Allocate: Chu")
  2924. explosive_count += 1
  2925.  
  2926. elif action == 'Arrow' and coin_flip > .5:
  2927.  
  2928. Allocate_Arrow(Heap, room.number, Overlay_Dict)
  2929. action_list.append("Allocate: Arrow")
  2930.  
  2931. elif action == 'Bomb' and coin_flip > .5 and explosive_count < 3:
  2932.  
  2933. Allocate_Bomb(Heap, room.number, Overlay_Dict)
  2934. action_list.append("Allocate: Bomb")
  2935. explosive_count += 1
  2936.  
  2937. elif action == 'Zora Fins' and coin_flip > .5:
  2938.  
  2939. Allocate_Zora_Fins(Heap, room.number, Overlay_Dict)
  2940. action_list.append("Allocate: Zora Fins")
  2941.  
  2942. elif action == 'Fish' and coin_flip > .5 and droppable_count < 2:
  2943.  
  2944. Allocate_Fish(Heap, room.number, Overlay_Dict)
  2945. action_list.append("Allocate: Fish")
  2946. droppable_count += 1
  2947.  
  2948. elif action == 'Bugs' and coin_flip > .5 and droppable_count < 2:
  2949.  
  2950. Allocate_Bugs(Heap, room.number, Overlay_Dict)
  2951. action_list.append("Allocate: Bugs")
  2952. droppable_count += 1
  2953.  
  2954. elif action == 'Hookshot' and coin_flip > .5:
  2955.  
  2956. Allocate_Hookshot(Heap, room.number, Overlay_Dict)
  2957. action_list.append("Allocate: Hookshot")
  2958. hookshot_exists = True
  2959.  
  2960. elif action == 'Charged Spin Attack' and (hookshot_exists is False) and coin_flip > .5:
  2961.  
  2962. Allocate_Charged_Spin_Attack(Heap, room.number, Overlay_Dict)
  2963. action_list.append("Allocate: Charged Spin Attack")
  2964.  
  2965. elif action == 'Gold Skulltula' and coin_flip > .5:
  2966.  
  2967. projectile_coin_flip = np.random.uniform(0,1)
  2968.  
  2969. if projectile_coin_flip > .5:
  2970. Allocate_Gold_Skulltula_With_Hookshot(Heap, room.number, Overlay_Dict)
  2971. action_list.append("Allocate: Gold Skulltula with Hookshot (hit painting)")
  2972.  
  2973. elif projectile_coin_flip <= .5:
  2974. Allocate_Gold_Skulltula_With_Arrow(Heap, room.number, Overlay_Dict)
  2975. action_list.append("Allocate: Gold Skulltula with Arrow (hit painting)")
  2976.  
  2977. else:
  2978.  
  2979. Load_Room(Heap, room, transition, Overlay_Dict)
  2980.  
  2981. action_list.append("Load Room: Room %d" %(room.number) + " with " + transition.name + " %d" %(transition.priority))
  2982.  
  2983. """
  2984.  
  2985. Now randomly (with some chosen distribution) choose things to allocate
  2986. and/or things to deallocate (in your current room). Make it so that
  2987. you can only choose a specific action once. For example, if allocation_list
  2988. has ['bomb', 'bomb, 'bomb', 'fish'] in it, then make it so you can only use
  2989. fish once, but you can use bomb 3 times
  2990.  
  2991. Somehow try to encode that hookshot/charged spin are mutually exclusive
  2992. and that if either of them exist then they must be the last action
  2993.  
  2994. Allow yourself to deallocate things before allocating things even
  2995. though it might be impossible or slow in some cases
  2996.  
  2997. """
  2998.  
  2999. # Do a coinflip to decide between allocating or deallocating first
  3000. #decision_coin_flip = np.random.uniform(0,1)
  3001. ##### Deterministically do deallocation step first
  3002. decision_coin_flip = 0
  3003.  
  3004. # With probability 1/2, we allocate first and deallocate second
  3005. # if we allocate first, don't allow 'Charged Spin Attack'
  3006. if decision_coin_flip > .5:
  3007.  
  3008. explosive_count = 0
  3009. droppable_count = 0
  3010.  
  3011. ##### ALLOCATION
  3012. for action in allocation_list_dict[room.number]:
  3013.  
  3014. # whether or not we add an action is based off of this
  3015. coin_flip = np.random.uniform(0,1)
  3016.  
  3017. if action == 'Smoke' and coin_flip > .5:
  3018.  
  3019. Allocate_Smoke(Heap, room.number, Overlay_Dict)
  3020. action_list.append("Allocate: Smoke")
  3021.  
  3022. elif action == 'Square Sign' and coin_flip > .5:
  3023.  
  3024. Allocate_Square_Sign(Heap, room.number, Overlay_Dict)
  3025. action_list.append("Allocate: Square Sign")
  3026.  
  3027. elif action == 'Chu' and coin_flip > .5 and explosive_count < 3:
  3028.  
  3029. Allocate_Chu(Heap, room.number, Overlay_Dict)
  3030. action_list.append("Allocate: Chu")
  3031. explosive_count += 1
  3032.  
  3033. elif action == 'Arrow' and coin_flip > .5:
  3034.  
  3035. Allocate_Arrow(Heap, room.number, Overlay_Dict)
  3036. action_list.append("Allocate: Arrow")
  3037.  
  3038. elif action == 'Bomb' and coin_flip > .5 and explosive_count < 3:
  3039.  
  3040. Allocate_Bomb(Heap, room.number, Overlay_Dict)
  3041. action_list.append("Allocate: Bomb")
  3042. explosive_count += 1
  3043.  
  3044. elif action == 'Zora Fins' and coin_flip > .5:
  3045.  
  3046. Allocate_Zora_Fins(Heap, room.number, Overlay_Dict)
  3047. action_list.append("Allocate: Zora Fins")
  3048.  
  3049. elif action == 'Fish' and coin_flip > .5 and droppable_count < 2:
  3050.  
  3051. Allocate_Fish(Heap, room.number, Overlay_Dict)
  3052. action_list.append("Allocate: Fish")
  3053. droppable_count += 1
  3054.  
  3055. elif action == 'Bugs' and coin_flip > .5 and droppable_count < 2:
  3056.  
  3057. Allocate_Bugs(Heap, room.number, Overlay_Dict)
  3058. action_list.append("Allocate: Bugs")
  3059. droppable_count += 1
  3060.  
  3061. elif action == 'Hookshot' and coin_flip > .5:
  3062.  
  3063. Allocate_Hookshot(Heap, room.number, Overlay_Dict)
  3064. action_list.append("Allocate: Hookshot")
  3065.  
  3066. elif action == 'Gold Skulltula' and coin_flip > .5:
  3067.  
  3068. projectile_coin_flip = np.random.uniform(0,1)
  3069.  
  3070. if projectile_coin_flip > .5:
  3071. Allocate_Gold_Skulltula_With_Hookshot(Heap, room.number, Overlay_Dict)
  3072. action_list.append("Allocate: Gold Skulltula with Hookshot (hit painting)")
  3073.  
  3074. elif projectile_coin_flip <= .5:
  3075. Allocate_Gold_Skulltula_With_Arrow(Heap, room.number, Overlay_Dict)
  3076. action_list.append("Allocate: Gold Skulltula with Arrow (hit painting)")
  3077.  
  3078. ### We don't include 'Charged Spin Attack' in this
  3079.  
  3080. ##### DEALLOCATION
  3081. for actor in room.priority_queue:
  3082.  
  3083. # whether or not we deallocate an actor is based off of this
  3084. coin_flip = np.random.uniform(0,1)
  3085.  
  3086. ##### HARDCODE TO NOT ALLOW GOLD SKULLTULA OR SPIDER WEBS DEALLOCATE BECAUSE FASTER FOR 100%
  3087. if actor.unloadable == True and Actor_Is_In_Heap(Heap, actor) == True and coin_flip > .5 and actor.Id != '0050' and actor.Id != '01F4' and actor.Id != '0125':
  3088.  
  3089.  
  3090. if actor.Id == '00E8' or actor.name == 'Collectible (Rupee from Rupee Cluster)':
  3091.  
  3092. Deallocate(Heap, actor, Overlay_Dict)
  3093. # There is at most one rupee cluster per room, so this is fine to clear it
  3094. Clear_Instances('00E8', room)
  3095. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3096.  
  3097. # THESE PRIORITIES ARE HARDCODED FOR ROOM 3 OF OCEANSIDE!!!!!!!
  3098. elif actor.Id == '01E7' and (actor.priority == 0 or actor.priority == 1 or actor.priority == 2):
  3099.  
  3100. table_bonk_deallocation_count = 0
  3101. for entry in Heap:
  3102. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 0:
  3103. Deallocate(Heap, entry, Overlay_Dict)
  3104. table_bonk_deallocation_count += 1
  3105.  
  3106. for entry in Heap:
  3107. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 1:
  3108. Deallocate(Heap, entry, Overlay_Dict)
  3109. table_bonk_deallocation_count += 1
  3110.  
  3111. for entry in Heap:
  3112. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 2:
  3113. Deallocate(Heap, entry, Overlay_Dict)
  3114. table_bonk_deallocation_count += 1
  3115.  
  3116. if table_bonk_deallocation_count != 3:
  3117. print("ERROR: table_bonk_deallocation_count is not 3 (Randomized_Solver() error)")
  3118.  
  3119. action_list.append("Deallocate: " + actor.name + " (Priority 0, 1, and 2) [Bonk Oceanside Table]")
  3120.  
  3121.  
  3122. # if the actor is clearable AND isn't a bad bat, then clear it when deallocating it if it isn't already cleared
  3123. elif actor.clearable == True and actor.cleared == False and actor.Id != '015B':
  3124.  
  3125. Deallocate(Heap, actor, Overlay_Dict)
  3126. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3127. # CLEAR THE ACTOR
  3128. Clear_Instance(actor, room)
  3129.  
  3130. else:
  3131.  
  3132. Deallocate(Heap, actor, Overlay_Dict)
  3133. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3134.  
  3135.  
  3136. # With probability 1/2, we deallocate first and allocate second
  3137. elif decision_coin_flip <= .5:
  3138.  
  3139. explosive_count = 0
  3140. droppable_count = 0
  3141. hookshot_exists = False
  3142.  
  3143. ##### DEALLOCATION
  3144. for actor in room.priority_queue:
  3145.  
  3146. # whether or not we deallocate an actor is based off of this
  3147. coin_flip = np.random.uniform(0,1)
  3148.  
  3149. ##### HARDCODE TO NOT ALLOW GOLD SKULLTULA OR SPIDER WEBS DEALLOCATE BECAUSE FASTER FOR 100%
  3150. if actor.unloadable == True and Actor_Is_In_Heap(Heap, actor) == True and coin_flip > .5 and actor.Id != '0050' and actor.Id != '01F4' and actor.Id != '0125':
  3151.  
  3152.  
  3153. if actor.Id == '00E8' or actor.name == 'Collectible (Rupee from Rupee Cluster)':
  3154.  
  3155. Deallocate(Heap, actor, Overlay_Dict)
  3156. # There is at most one rupee cluster per room, so this is fine to clear it
  3157. Clear_Instances('00E8', room)
  3158. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3159.  
  3160. # THESE PRIORITIES ARE HARDCODED FOR ROOM 3 OF OCEANSIDE!!!!!!!
  3161. elif actor.Id == '01E7' and (actor.priority == 0 or actor.priority == 1 or actor.priority == 2):
  3162.  
  3163. table_bonk_deallocation_count = 0
  3164. for entry in Heap:
  3165. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 0:
  3166. Deallocate(Heap, entry, Overlay_Dict)
  3167. table_bonk_deallocation_count += 1
  3168.  
  3169. for entry in Heap:
  3170. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 1:
  3171. Deallocate(Heap, entry, Overlay_Dict)
  3172. table_bonk_deallocation_count += 1
  3173.  
  3174. for entry in Heap:
  3175. if type(entry) == Actor and entry.Id == '01E7' and entry.priority == 2:
  3176. Deallocate(Heap, entry, Overlay_Dict)
  3177. table_bonk_deallocation_count += 1
  3178.  
  3179. if table_bonk_deallocation_count != 3:
  3180. print("ERROR: table_bonk_deallocation_count is not 3 (Randomized_Solver() error)")
  3181.  
  3182. action_list.append("Deallocate: " + actor.name + " (Priority 0, 1, and 2) [Bonk Oceanside Table]")
  3183.  
  3184.  
  3185. # if the actor is clearable AND isn't a bad bat, then clear it when deallocating it if it isn't already cleared
  3186. elif actor.clearable == True and actor.cleared == False and actor.Id != '015B':
  3187.  
  3188. Deallocate(Heap, actor, Overlay_Dict)
  3189. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3190. # CLEAR THE ACTOR
  3191. Clear_Instance(actor, room)
  3192.  
  3193. else:
  3194.  
  3195. Deallocate(Heap, actor, Overlay_Dict)
  3196. action_list.append("Deallocate: " + actor.name + " (Priority %d)" %(actor.priority))
  3197.  
  3198.  
  3199. ##### ALLOCATION
  3200. for action in allocation_list_dict[room.number]:
  3201.  
  3202. # whether or not we add an action is based off of this
  3203. coin_flip = np.random.uniform(0,1)
  3204.  
  3205. if action == 'Smoke' and coin_flip > .5:
  3206.  
  3207. Allocate_Smoke(Heap, room.number, Overlay_Dict)
  3208. action_list.append("Allocate: Smoke")
  3209.  
  3210. elif action == 'Square Sign' and coin_flip > .5:
  3211.  
  3212. Allocate_Square_Sign(Heap, room.number, Overlay_Dict)
  3213. action_list.append("Allocate: Square Sign")
  3214.  
  3215. elif action == 'Chu' and coin_flip > .5 and explosive_count < 3:
  3216.  
  3217. Allocate_Chu(Heap, room.number, Overlay_Dict)
  3218. action_list.append("Allocate: Chu")
  3219. explosive_count += 1
  3220.  
  3221. elif action == 'Arrow' and coin_flip > .5:
  3222.  
  3223. Allocate_Arrow(Heap, room.number, Overlay_Dict)
  3224. action_list.append("Allocate: Arrow")
  3225.  
  3226. elif action == 'Bomb' and coin_flip > .5 and explosive_count < 3:
  3227.  
  3228. Allocate_Bomb(Heap, room.number, Overlay_Dict)
  3229. action_list.append("Allocate: Bomb")
  3230. explosive_count += 1
  3231.  
  3232. elif action == 'Zora Fins' and coin_flip > .5:
  3233.  
  3234. Allocate_Zora_Fins(Heap, room.number, Overlay_Dict)
  3235. action_list.append("Allocate: Zora Fins")
  3236.  
  3237. elif action == 'Fish' and coin_flip > .5 and droppable_count < 2:
  3238.  
  3239. Allocate_Fish(Heap, room.number, Overlay_Dict)
  3240. action_list.append("Allocate: Fish")
  3241. droppable_count += 1
  3242.  
  3243. elif action == 'Bugs' and coin_flip > .5 and droppable_count < 2:
  3244.  
  3245. Allocate_Bugs(Heap, room.number, Overlay_Dict)
  3246. action_list.append("Allocate: Bugs")
  3247. droppable_count += 1
  3248.  
  3249. elif action == 'Hookshot' and coin_flip > .5:
  3250.  
  3251. Allocate_Hookshot(Heap, room.number, Overlay_Dict)
  3252. action_list.append("Allocate: Hookshot")
  3253. hookshot_exists = True
  3254.  
  3255. elif action == 'Charged Spin Attack' and (hookshot_exists is False) and coin_flip > .5:
  3256.  
  3257. Allocate_Charged_Spin_Attack(Heap, room.number, Overlay_Dict)
  3258. action_list.append("Allocate: Charged Spin Attack")
  3259.  
  3260. elif action == 'Gold Skulltula' and coin_flip > .5:
  3261.  
  3262. projectile_coin_flip = np.random.uniform(0,1)
  3263.  
  3264. if projectile_coin_flip > .5:
  3265. Allocate_Gold_Skulltula_With_Hookshot(Heap, room.number, Overlay_Dict)
  3266. action_list.append("Allocate: Gold Skulltula with Hookshot (hit painting)")
  3267.  
  3268. elif projectile_coin_flip <= .5:
  3269. Allocate_Gold_Skulltula_With_Arrow(Heap, room.number, Overlay_Dict)
  3270. action_list.append("Allocate: Gold Skulltula with Arrow (hit painting)")
  3271.  
  3272. room_count += 1
  3273.  
  3274. ##### Now we load the last room in room_order_list
  3275. current_room = Current_Room(room_load_list, Room_List)
  3276. most_recent_transition = room_load_list[-1]
  3277. Load_Room(Heap, current_room, most_recent_transition, Overlay_Dict)
  3278.  
  3279. action_list.append("Load Room: Room %d" %(current_room.number) + " with " + most_recent_transition.name + " %d" %(most_recent_transition.priority))
  3280.  
  3281.  
  3282. """
  3283.  
  3284. Now that we have iterated through all of the rooms, we want to check to see
  3285. if we are in a room with a valid grabbale object. If so, then store the addresses
  3286. of all of them and make a copy of the current Heap state. From here, we want to try
  3287. every possibility in the sense that we want to check every valid grabbable object
  3288. in every room that we can get to and also check every superslide case that is possible
  3289. (based on the binary number associated with each valid grabbable object) and then
  3290. check if either the Angle or Position (input this into the function via Offset_List)
  3291. line up with the chest or deku guard
  3292.  
  3293. There aren't too many possibilities from here in practice, so we might as well check them all
  3294.  
  3295. Also encode that if we superslide into a room with a chest/deku guard, then we must
  3296. exit the room and then reenter it (or enter another room with a chest/deku guard; we will
  3297. test every case) and after doing that we will check the chest/deku guard addresses
  3298. and see if any of them line up with any of the pots that we stored the addresses of
  3299.  
  3300. We'll eventually want to write stuff to a text file, so maybe set file as an input argument
  3301. or just hardcode it, not sure
  3302.  
  3303. """
  3304.  
  3305. """
  3306.  
  3307. WE MAKE THE ASSUMPTION THAT YOU LAND IN A ROOM THAT EITHER IS A ROOM
  3308. WITH A CHEST/DEKU GUARD OR A ROOM THAT NEIGHBORS A ROOM WITH A CHEST/DEKU GUARD
  3309. BECAUSE I CANNOT THINK OF ANY PLACES WHERE THIS WOULDN'T HAPPEN WHEN TESTING
  3310. SUPERSLIDE SRM (ZORA FIN WOULD BE DIFFERENT, BUT THIS SOLVER DOESN'T TEST IT)
  3311.  
  3312. Also, before supersliding, we assume that you're in a room that either has
  3313. a valid grabbable object, or is next to a room with a valid grabbable object.
  3314. Of course, this means fewer possibilities are being tested in a place like
  3315. oceanside, but there are already so many possibilities to test to begin with that
  3316. this probably isn't a big deal for now. This also affects deku palace, but maybe
  3317. I'll change this by the time I work on deku palace (because if you end in Room2,
  3318. then nothing happens)
  3319.  
  3320. """
  3321.  
  3322. """
  3323.  
  3324. Nevermind some of those other comments, here is what I'm really assuming.
  3325.  
  3326. I will be assuming that if you end in a room without a valid grabbable
  3327. actor, then it will search all neighbors of that room for valid grabbable
  3328. actors and if none of those have valid grabbable objects then it will
  3329. search all of those neighbors and choose the first one it finds (this
  3330. will allow for ending in Room 2 in Deku Palace). Otherwise it does nothing
  3331. (though this will never happen for the cases I plan on checking for now)
  3332.  
  3333. (*Coded)If you are in a room with a valid grabbable actor and no chest/deku guard,
  3334. then we will check the addresses of all valid grabbable actors in this room
  3335. and superslide into the chest room, exit and reenter it. Then we will check the address of the
  3336. chest and see if it lines up with any of the pot addresses from the previous
  3337. room.
  3338.  
  3339. (*Coded)If you are in a room with a valid grabbable actor AND a chest/deku guard, then
  3340. you will record the valid grabbable actor addresses then superslide to exit the
  3341. room and then check all neighbors of the room you enter for having a chest/deku guard
  3342. and test all of them
  3343.  
  3344.  
  3345.  
  3346. """
  3347.  
  3348. valid_grabbable_actor_room_list = []
  3349.  
  3350. for room in Room_List:
  3351. if Valid_Grabbable_In_Room(room, Grabbable_Dict) is True:
  3352. valid_grabbable_actor_room_list.append(room)
  3353.  
  3354. # This gives a list of all ways we can exit our current room
  3355. #transition_list_possibilities = Generate_Room_Load_Permutations(current_room, Room_List, 1)
  3356.  
  3357. ##### Case 1: there is a valid grabbable actor in the current room, but no chest/deku guard (the guard thing doesn't matter because this never happens in palace anyway)
  3358. if (current_room in valid_grabbable_actor_room_list) and (Chest_In_Room(current_room) is False) and (Deku_Guard_In_Room(current_room) is False):
  3359.  
  3360. valid_pot_list = []
  3361. pot_address_list = []
  3362.  
  3363. for pot in Grabbable_Dict:
  3364.  
  3365. if Actor_Is_In_Room(current_room, pot) is True:
  3366. valid_pot_list.append(pot)
  3367. pot_address_list.append(pot.address)
  3368.  
  3369. """
  3370.  
  3371. Now for each pot in valid_pot_list, we want to test every applicable
  3372. superslide scenario
  3373.  
  3374. Before each one, we need to copy the current state and then modify the copies
  3375. to check for the solution
  3376.  
  3377. """
  3378.  
  3379. for pot in valid_pot_list:
  3380.  
  3381. # both bomb and smoke loaded on superslide
  3382. if Grabbable_Dict[pot][0][0] == '1':
  3383.  
  3384. action_list100 = []
  3385.  
  3386. # COPY STATE
  3387. #######################################################
  3388. Room_List_Copy = Copy_Room_List(Room_List)
  3389. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3390.  
  3391. room_copy_dict = {}
  3392. for room in Room_List_Copy:
  3393. room_copy_dict[room.number] = room
  3394.  
  3395. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3396.  
  3397. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3398. #######################################################
  3399.  
  3400. Bomb_And_Smoke_Superslide(Heap_Copy, current_room.number, Overlay_Dict_Copy)
  3401. action_list100.append("Superslide with Bomb and Smoke still allocated")
  3402.  
  3403. # The room we superslide into through the plane corresponding to the given pot
  3404. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3405.  
  3406. destination_room_copy = room_copy_dict[destination_room.number]
  3407. current_room_copy = room_copy_dict[current_room.number]
  3408.  
  3409. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3410. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3411.  
  3412. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3413. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3414.  
  3415. # Now exit the chest room
  3416. Load_Room(Heap_Copy, current_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3417. action_list100.append("Load Room: Room %d" %(current_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3418.  
  3419. # Now reenter the chest room
  3420. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3421. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3422.  
  3423. ##### Now check for chests/deku guards
  3424.  
  3425. chest_guard_list = []
  3426.  
  3427. for entry in Heap_Copy:
  3428.  
  3429. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3430. chest_guard_list.append(entry)
  3431.  
  3432. soln_found = False
  3433. for entry in chest_guard_list:
  3434. if (pot.address - entry.address) in Offset_List:
  3435.  
  3436. action_list100.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3437.  
  3438. if (pot.address - entry.address) == 0x160:
  3439. angle_solution_count += 1
  3440. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3441. elif (pot.address - entry.address) == 0x1F0:
  3442. position_solution_count += 1
  3443. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3444.  
  3445. soln_found = True
  3446.  
  3447. if soln_found is True:
  3448. total_action_list = action_list + action_list100
  3449.  
  3450. # the "a" argument is important so we don't overwrite previous solutions
  3451. with open(filename, "a") as file:
  3452.  
  3453. for action in total_action_list:
  3454.  
  3455. file.write(action + "\n")
  3456. file.write("-----\n")
  3457.  
  3458.  
  3459. ##### Only smoke is loaded from superslide
  3460. elif Grabbable_Dict[pot][0][1] == '1':
  3461.  
  3462. action_list010 = []
  3463.  
  3464. # COPY STATE
  3465. #######################################################
  3466. Room_List_Copy = Copy_Room_List(Room_List)
  3467. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3468.  
  3469. room_copy_dict = {}
  3470. for room in Room_List_Copy:
  3471. room_copy_dict[room.number] = room
  3472.  
  3473. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3474.  
  3475. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3476. #######################################################
  3477.  
  3478. Allocate_Smoke(Heap_Copy, current_room.number, Overlay_Dict_Copy)
  3479. action_list010.append("Superslide with Smoke still allocated")
  3480.  
  3481. # The room we superslide into through the plane corresponding to the given pot
  3482. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3483.  
  3484. destination_room_copy = room_copy_dict[destination_room.number]
  3485. current_room_copy = room_copy_dict[current_room.number]
  3486.  
  3487. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3488. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3489.  
  3490. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3491. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3492.  
  3493. # Now exit the chest room
  3494. Load_Room(Heap_Copy, current_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3495. action_list010.append("Load Room: Room %d" %(current_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3496.  
  3497. # Now reenter the chest room
  3498. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3499. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3500.  
  3501.  
  3502. ##### Now check for chests/deku guards
  3503.  
  3504. chest_guard_list = []
  3505.  
  3506. for entry in Heap_Copy:
  3507.  
  3508. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3509. chest_guard_list.append(entry)
  3510.  
  3511. soln_found = False
  3512. for entry in chest_guard_list:
  3513. if (pot.address - entry.address) in Offset_List:
  3514.  
  3515. action_list010.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3516.  
  3517. if (pot.address - entry.address) == 0x160:
  3518. angle_solution_count += 1
  3519. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3520. elif (pot.address - entry.address) == 0x1F0:
  3521. position_solution_count += 1
  3522. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3523.  
  3524. soln_found = True
  3525.  
  3526. if soln_found is True:
  3527. total_action_list = action_list + action_list010
  3528.  
  3529. # the "a" argument is important so we don't overwrite previous solutions
  3530. with open(filename, "a") as file:
  3531.  
  3532. for action in total_action_list:
  3533.  
  3534. file.write(action + "\n")
  3535. file.write("-----\n")
  3536.  
  3537.  
  3538. #### Bomb and Smoke are both unloaded
  3539. elif Grabbable_Dict[pot][0][2] == '1':
  3540.  
  3541. action_list001 = []
  3542.  
  3543. # COPY STATE
  3544. #######################################################
  3545. Room_List_Copy = Copy_Room_List(Room_List)
  3546. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3547.  
  3548. room_copy_dict = {}
  3549. for room in Room_List_Copy:
  3550. room_copy_dict[room.number] = room
  3551.  
  3552. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3553.  
  3554. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3555. #######################################################
  3556.  
  3557. # Do not allocate anything
  3558. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  3559.  
  3560. # The room we superslide into through the plane corresponding to the given pot
  3561. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3562.  
  3563. destination_room_copy = room_copy_dict[destination_room.number]
  3564. current_room_copy = room_copy_dict[current_room.number]
  3565.  
  3566. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3567. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3568.  
  3569. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3570. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3571.  
  3572. # Now exit the chest room
  3573. Load_Room(Heap_Copy, current_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3574. action_list001.append("Load Room: Room %d" %(current_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3575.  
  3576. # Now reenter the chest room
  3577. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3578. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3579.  
  3580.  
  3581. ##### Now check for chests/deku guards
  3582.  
  3583. chest_guard_list = []
  3584.  
  3585. for entry in Heap_Copy:
  3586.  
  3587. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3588. chest_guard_list.append(entry)
  3589.  
  3590. soln_found = False
  3591. for entry in chest_guard_list:
  3592. if (pot.address - entry.address) in Offset_List:
  3593.  
  3594. action_list001.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3595.  
  3596. if (pot.address - entry.address) == 0x160:
  3597. angle_solution_count += 1
  3598. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3599. elif (pot.address - entry.address) == 0x1F0:
  3600. position_solution_count += 1
  3601. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3602.  
  3603. soln_found = True
  3604.  
  3605. if soln_found is True:
  3606. total_action_list = action_list + action_list001
  3607.  
  3608. # the "a" argument is important so we don't overwrite previous solutions
  3609. with open(filename, "a") as file:
  3610.  
  3611. for action in total_action_list:
  3612.  
  3613. file.write(action + "\n")
  3614. file.write("-----\n")
  3615.  
  3616.  
  3617.  
  3618. # Case 2: there is a valid grabbable actor in the current room AND there is a chest or deku guard
  3619. elif (current_room in valid_grabbable_actor_room_list) and ((Chest_In_Room(current_room) is True) or (Deku_Guard_In_Room(current_room) is True)):
  3620.  
  3621. valid_pot_list = []
  3622. pot_address_list = []
  3623.  
  3624. for pot in Grabbable_Dict:
  3625.  
  3626. if Actor_Is_In_Room(current_room, pot) is True:
  3627. valid_pot_list.append(pot)
  3628. pot_address_list.append(pot.address)
  3629.  
  3630.  
  3631. """
  3632.  
  3633. Now for each pot in valid_pot_list, we want to test every applicable
  3634. superslide scenario
  3635.  
  3636. Before each one, we need to copy the current state and then modify the copies
  3637. to check for the solution
  3638.  
  3639. Also, for every case, we need to consider every possible room that contains
  3640. a chest/deku guard that neighbors the room we just entered (meaning you
  3641. will need to make copies of the copies of the state)
  3642.  
  3643. """
  3644.  
  3645. for pot in valid_pot_list:
  3646.  
  3647. # both bomb and smoke loaded on superslide
  3648. if Grabbable_Dict[pot][0][0] == '1':
  3649.  
  3650. action_list100 = []
  3651.  
  3652. # COPY STATE
  3653. #######################################################
  3654. Room_List_Copy = Copy_Room_List(Room_List)
  3655. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3656.  
  3657. room_copy_dict = {}
  3658. for room in Room_List_Copy:
  3659. room_copy_dict[room.number] = room
  3660.  
  3661. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3662.  
  3663. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3664. #######################################################
  3665.  
  3666. Bomb_And_Smoke_Superslide(Heap_Copy, current_room.number, Overlay_Dict_Copy)
  3667. action_list100.append("Superslide with Bomb and Smoke still allocated")
  3668.  
  3669. # The room we superslide into through the plane corresponding to the given pot
  3670. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3671.  
  3672. destination_room_copy = room_copy_dict[destination_room.number]
  3673.  
  3674. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3675. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3676.  
  3677. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3678. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3679.  
  3680. """
  3681.  
  3682. Now we check all neighbors of our current room (destination_room) and for
  3683. each neighbor that has a chest or deku guard in it, we will create a copy
  3684. of our copy of the state, then enter each of them through each possible
  3685. loading plane and then check the chest/guard addresses and see if anything
  3686. lines up
  3687.  
  3688. """
  3689.  
  3690. for neighbor in Neighbors(destination_room, Room_List):
  3691.  
  3692. if Chest_In_Room(neighbor) == True or Deku_Guard_In_Room(neighbor) == True:
  3693.  
  3694. for transition in Shared_Transitions(destination_room, neighbor):
  3695.  
  3696. # COPY STATE
  3697. #######################################################
  3698. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  3699. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  3700.  
  3701. room_copy_dict_2 = {}
  3702. for room in Room_List_Copy_2:
  3703. room_copy_dict_2[room.number] = room
  3704.  
  3705. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  3706.  
  3707. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  3708. #######################################################
  3709.  
  3710. action_list_2 = []
  3711.  
  3712. transition_copy = Find_Actor_Copy(transition, Room_List_Copy_2)
  3713.  
  3714. neighbor_copy = room_copy_dict_2[neighbor.number]
  3715.  
  3716. Load_Room(Heap_Copy_2, neighbor_copy, transition_copy, Overlay_Dict_Copy_2)
  3717. action_list_2.append("Load Room: Room %d" %(neighbor_copy.number) + " with " + transition_copy.name + " %d" %(transition_copy.priority))
  3718.  
  3719.  
  3720. ##### Now check for chests/deku guards
  3721.  
  3722. chest_guard_list = []
  3723.  
  3724. for entry in Heap_Copy_2:
  3725.  
  3726. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3727. chest_guard_list.append(entry)
  3728.  
  3729. soln_found = False
  3730. for entry in chest_guard_list:
  3731. if (pot.address - entry.address) in Offset_List:
  3732.  
  3733. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3734.  
  3735. if (pot.address - entry.address) == 0x160:
  3736. angle_solution_count += 1
  3737. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3738. elif (pot.address - entry.address) == 0x1F0:
  3739. position_solution_count += 1
  3740. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3741.  
  3742. soln_found = True
  3743.  
  3744. if soln_found is True:
  3745. total_action_list = action_list + action_list100 + action_list_2
  3746.  
  3747. # the "a" argument is important so we don't overwrite previous solutions
  3748. with open(filename, "a") as file:
  3749.  
  3750. for action in total_action_list:
  3751.  
  3752. file.write(action + "\n")
  3753. file.write("-----\n")
  3754.  
  3755.  
  3756. ##### Only smoke is loaded from superslide
  3757. elif Grabbable_Dict[pot][0][1] == '1':
  3758.  
  3759. action_list010 = []
  3760.  
  3761. # COPY STATE
  3762. #######################################################
  3763. Room_List_Copy = Copy_Room_List(Room_List)
  3764. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3765.  
  3766. room_copy_dict = {}
  3767. for room in Room_List_Copy:
  3768. room_copy_dict[room.number] = room
  3769.  
  3770. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3771.  
  3772. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3773. #######################################################
  3774.  
  3775. Allocate_Smoke(Heap_Copy, current_room.number, Overlay_Dict_Copy)
  3776. action_list010.append("Superslide with Smoke still allocated")
  3777.  
  3778. # The room we superslide into through the plane corresponding to the given pot
  3779. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3780.  
  3781. destination_room_copy = room_copy_dict[destination_room.number]
  3782.  
  3783. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3784. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3785.  
  3786. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3787. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3788.  
  3789. """
  3790.  
  3791. Now we check all neighbors of our current room (destination_room) and for
  3792. each neighbor that has a chest or deku guard in it, we will create a copy
  3793. of our copy of the state, then enter each of them through each possible
  3794. loading plane and then check the chest/guard addresses and see if anything
  3795. lines up
  3796.  
  3797. """
  3798.  
  3799. for neighbor in Neighbors(destination_room, Room_List):
  3800.  
  3801. if Chest_In_Room(neighbor) == True or Deku_Guard_In_Room(neighbor) == True:
  3802.  
  3803. for transition in Shared_Transitions(destination_room, neighbor):
  3804.  
  3805. # COPY STATE
  3806. #######################################################
  3807. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  3808. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  3809.  
  3810. room_copy_dict_2 = {}
  3811. for room in Room_List_Copy_2:
  3812. room_copy_dict_2[room.number] = room
  3813.  
  3814. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  3815.  
  3816. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  3817. #######################################################
  3818.  
  3819. action_list_2 = []
  3820.  
  3821. transition_copy = Find_Actor_Copy(transition, Room_List_Copy_2)
  3822.  
  3823. neighbor_copy = room_copy_dict_2[neighbor.number]
  3824.  
  3825. Load_Room(Heap_Copy_2, neighbor_copy, transition_copy, Overlay_Dict_Copy_2)
  3826. action_list_2.append("Load Room: Room %d" %(neighbor_copy.number) + " with " + transition_copy.name + " %d" %(transition_copy.priority))
  3827.  
  3828.  
  3829. ##### Now check for chests/deku guards
  3830.  
  3831. chest_guard_list = []
  3832.  
  3833. for entry in Heap_Copy_2:
  3834.  
  3835. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3836. chest_guard_list.append(entry)
  3837.  
  3838. soln_found = False
  3839. for entry in chest_guard_list:
  3840. if (pot.address - entry.address) in Offset_List:
  3841.  
  3842. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3843.  
  3844. if (pot.address - entry.address) == 0x160:
  3845. angle_solution_count += 1
  3846. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3847. elif (pot.address - entry.address) == 0x1F0:
  3848. position_solution_count += 1
  3849. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3850.  
  3851. soln_found = True
  3852.  
  3853. if soln_found is True:
  3854. total_action_list = action_list + action_list010 + action_list_2
  3855.  
  3856. # the "a" argument is important so we don't overwrite previous solutions
  3857. with open(filename, "a") as file:
  3858.  
  3859. for action in total_action_list:
  3860.  
  3861. file.write(action + "\n")
  3862. file.write("-----\n")
  3863.  
  3864.  
  3865. #### Bomb and Smoke are both unloaded
  3866. elif Grabbable_Dict[pot][0][2] == '1':
  3867.  
  3868. action_list001 = []
  3869.  
  3870. # COPY STATE
  3871. #######################################################
  3872. Room_List_Copy = Copy_Room_List(Room_List)
  3873. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3874.  
  3875. room_copy_dict = {}
  3876. for room in Room_List_Copy:
  3877. room_copy_dict[room.number] = room
  3878.  
  3879. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3880.  
  3881. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  3882. #######################################################
  3883.  
  3884. # Do not allocate anything
  3885. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  3886.  
  3887. # The room we superslide into through the plane corresponding to the given pot
  3888. destination_room = Current_Room([current_room, Grabbable_Dict[pot][1]], Room_List)
  3889.  
  3890. destination_room_copy = room_copy_dict[destination_room.number]
  3891.  
  3892. pot_copy = Find_Actor_Copy(pot, Room_List_Copy)
  3893. superslide_transition_copy = Grabbable_Dict_Copy[pot_copy][1]
  3894.  
  3895. Load_Room(Heap_Copy, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy)
  3896. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  3897.  
  3898. """
  3899.  
  3900. Now we check all neighbors of our current room (destination_room) and for
  3901. each neighbor that has a chest or deku guard in it, we will create a copy
  3902. of our copy of the state, then enter each of them through each possible
  3903. loading plane and then check the chest/guard addresses and see if anything
  3904. lines up
  3905.  
  3906. """
  3907.  
  3908. for neighbor in Neighbors(destination_room, Room_List):
  3909.  
  3910. if Chest_In_Room(neighbor) == True or Deku_Guard_In_Room(neighbor) == True:
  3911.  
  3912. for transition in Shared_Transitions(destination_room, neighbor):
  3913.  
  3914. # COPY STATE
  3915. #######################################################
  3916. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  3917. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  3918.  
  3919. room_copy_dict_2 = {}
  3920. for room in Room_List_Copy_2:
  3921. room_copy_dict_2[room.number] = room
  3922.  
  3923. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  3924.  
  3925. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  3926. #######################################################
  3927.  
  3928. action_list_2 = []
  3929.  
  3930. transition_copy = Find_Actor_Copy(transition, Room_List_Copy_2)
  3931.  
  3932. neighbor_copy = room_copy_dict_2[neighbor.number]
  3933.  
  3934. Load_Room(Heap_Copy_2, neighbor_copy, transition_copy, Overlay_Dict_Copy_2)
  3935. action_list_2.append("Load Room: Room %d" %(neighbor_copy.number) + " with " + transition_copy.name + " %d" %(transition_copy.priority))
  3936.  
  3937.  
  3938. ##### Now check for chests/deku guards
  3939.  
  3940. chest_guard_list = []
  3941.  
  3942. for entry in Heap_Copy_2:
  3943.  
  3944. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  3945. chest_guard_list.append(entry)
  3946.  
  3947. soln_found = False
  3948. for entry in chest_guard_list:
  3949. if (pot.address - entry.address) in Offset_List:
  3950.  
  3951. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  3952.  
  3953. if (pot.address - entry.address) == 0x160:
  3954. angle_solution_count += 1
  3955. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3956. elif (pot.address - entry.address) == 0x1F0:
  3957. position_solution_count += 1
  3958. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  3959.  
  3960. soln_found = True
  3961.  
  3962. if soln_found is True:
  3963. total_action_list = action_list + action_list001 + action_list_2
  3964.  
  3965. # the "a" argument is important so we don't overwrite previous solutions
  3966. with open(filename, "a") as file:
  3967.  
  3968. for action in total_action_list:
  3969.  
  3970. file.write(action + "\n")
  3971. file.write("-----\n")
  3972.  
  3973.  
  3974. ##### Case 3: there is NOT a valid grabbable actor in the current room
  3975. elif (current_room not in valid_grabbable_actor_room_list):
  3976.  
  3977. for neighbor in Neighbors(current_room, Room_List):
  3978.  
  3979. ##### Valid grabbable actor in neighbor
  3980. if neighbor in valid_grabbable_actor_room_list:
  3981.  
  3982.  
  3983. # For every transition in Shared_Transitions(current_room, neighbor)
  3984. for transition in Shared_Transitions(current_room, neighbor):
  3985.  
  3986. action_list_transition = []
  3987.  
  3988. ##### COPY THE STATE
  3989. #######################################################
  3990. Room_List_Copy = Copy_Room_List(Room_List)
  3991. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  3992.  
  3993. room_copy_dict = {}
  3994. for room in Room_List_Copy:
  3995. room_copy_dict[room.number] = room
  3996.  
  3997. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  3998.  
  3999. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  4000. #######################################################
  4001.  
  4002. ##### ENTER neighbor after copying it
  4003.  
  4004. neighbor_copy = room_copy_dict[neighbor.number]
  4005. transition_copy = Find_Actor_Copy(transition, Room_List_Copy)
  4006.  
  4007. Load_Room(Heap_Copy, neighbor_copy, transition_copy, Overlay_Dict_Copy)
  4008. action_list_transition.append("Load Room: Room %d" %(neighbor_copy.number) + " with " + transition_copy.name + " %d" %(transition_copy.priority))
  4009.  
  4010.  
  4011. ##### Iterate through all pots in this room
  4012.  
  4013. valid_pot_list = []
  4014. pot_address_list = []
  4015.  
  4016. for pot in Grabbable_Dict_Copy:
  4017.  
  4018. if Actor_Is_In_Room(neighbor_copy, pot) is True:
  4019. valid_pot_list.append(pot)
  4020. pot_address_list.append(pot.address)
  4021.  
  4022.  
  4023.  
  4024. # If there is a chest/guard, superslide, then check neighbors for chests/guards and test all (copy state)
  4025. if Chest_In_Room(neighbor) == True or Deku_Guard_In_Room(neighbor) == True:
  4026.  
  4027. for pot in valid_pot_list:
  4028.  
  4029. # both bomb and smoke loaded on superslide
  4030. if Grabbable_Dict_Copy[pot][0][0] == '1':
  4031.  
  4032. action_list100 = []
  4033.  
  4034. # COPY STATE
  4035. #######################################################
  4036. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4037. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4038.  
  4039. room_copy_dict_SS = {}
  4040. for room in Room_List_Copy_SS:
  4041. room_copy_dict_SS[room.number] = room
  4042.  
  4043. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4044.  
  4045. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4046. #######################################################
  4047.  
  4048. Bomb_And_Smoke_Superslide(Heap_Copy_SS, neighbor.number, Overlay_Dict_Copy_SS)
  4049. action_list100.append("Superslide with Bomb and Smoke still allocated")
  4050.  
  4051. # The room we superslide into through the plane corresponding to the given pot
  4052. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4053.  
  4054. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4055.  
  4056. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4057. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4058.  
  4059. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4060. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4061.  
  4062. """
  4063.  
  4064. Now we check all neighbors of our current room (destination_room) and for
  4065. each neighbor that has a chest or deku guard in it, we will create a copy
  4066. of our copy of the state, then enter each of them through each possible
  4067. loading plane and then check the chest/guard addresses and see if anything
  4068. lines up
  4069.  
  4070. """
  4071.  
  4072. for bordering_room in Neighbors(destination_room, Room_List):
  4073.  
  4074. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4075.  
  4076. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4077.  
  4078. # COPY STATE
  4079. #######################################################
  4080. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4081. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4082.  
  4083. room_copy_dict_2 = {}
  4084. for room in Room_List_Copy_2:
  4085. room_copy_dict_2[room.number] = room
  4086.  
  4087. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4088.  
  4089. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4090. #######################################################
  4091.  
  4092. action_list_2 = []
  4093.  
  4094. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4095.  
  4096. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4097.  
  4098. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4099. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4100.  
  4101.  
  4102. ##### Now check for chests/deku guards
  4103.  
  4104. chest_guard_list = []
  4105.  
  4106. for entry in Heap_Copy_2:
  4107.  
  4108. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4109. chest_guard_list.append(entry)
  4110.  
  4111. soln_found = False
  4112. for entry in chest_guard_list:
  4113. if (pot.address - entry.address) in Offset_List:
  4114.  
  4115. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4116.  
  4117. if (pot.address - entry.address) == 0x160:
  4118. angle_solution_count += 1
  4119. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4120. elif (pot.address - entry.address) == 0x1F0:
  4121. position_solution_count += 1
  4122. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4123.  
  4124. soln_found = True
  4125.  
  4126. if soln_found is True:
  4127. total_action_list = action_list + action_list_transition + action_list100 + action_list_2
  4128.  
  4129. # the "a" argument is important so we don't overwrite previous solutions
  4130. with open(filename, "a") as file:
  4131.  
  4132. for action in total_action_list:
  4133.  
  4134. file.write(action + "\n")
  4135. file.write("-----\n")
  4136.  
  4137.  
  4138.  
  4139. ##### Only smoke is loaded from superslide
  4140. elif Grabbable_Dict_Copy[pot][0][1] == '1':
  4141.  
  4142. action_list010 = []
  4143.  
  4144. # COPY STATE
  4145. #######################################################
  4146. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4147. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4148.  
  4149. room_copy_dict_SS = {}
  4150. for room in Room_List_Copy_SS:
  4151. room_copy_dict_SS[room.number] = room
  4152.  
  4153. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4154.  
  4155. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4156. #######################################################
  4157.  
  4158. Allocate_Smoke(Heap_Copy_SS, neighbor.number, Overlay_Dict_Copy_SS)
  4159. action_list010.append("Superslide with Smoke still allocated")
  4160.  
  4161. # The room we superslide into through the plane corresponding to the given pot
  4162. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4163.  
  4164. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4165.  
  4166. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4167. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4168.  
  4169. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4170. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4171.  
  4172. """
  4173.  
  4174. Now we check all neighbors of our current room (destination_room) and for
  4175. each neighbor that has a chest or deku guard in it, we will create a copy
  4176. of our copy of the state, then enter each of them through each possible
  4177. loading plane and then check the chest/guard addresses and see if anything
  4178. lines up
  4179.  
  4180. """
  4181.  
  4182. for bordering_room in Neighbors(destination_room, Room_List):
  4183.  
  4184. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4185.  
  4186. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4187.  
  4188. # COPY STATE
  4189. #######################################################
  4190. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4191. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4192.  
  4193. room_copy_dict_2 = {}
  4194. for room in Room_List_Copy_2:
  4195. room_copy_dict_2[room.number] = room
  4196.  
  4197. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4198.  
  4199. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4200. #######################################################
  4201.  
  4202. action_list_2 = []
  4203.  
  4204. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4205.  
  4206. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4207.  
  4208. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4209. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4210.  
  4211.  
  4212. ##### Now check for chests/deku guards
  4213.  
  4214. chest_guard_list = []
  4215.  
  4216. for entry in Heap_Copy_2:
  4217.  
  4218. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4219. chest_guard_list.append(entry)
  4220.  
  4221. soln_found = False
  4222. for entry in chest_guard_list:
  4223. if (pot.address - entry.address) in Offset_List:
  4224.  
  4225. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4226.  
  4227. if (pot.address - entry.address) == 0x160:
  4228. angle_solution_count += 1
  4229. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4230. elif (pot.address - entry.address) == 0x1F0:
  4231. position_solution_count += 1
  4232. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4233.  
  4234. soln_found = True
  4235.  
  4236. if soln_found is True:
  4237. total_action_list = action_list + action_list_transition + action_list010 + action_list_2
  4238.  
  4239. # the "a" argument is important so we don't overwrite previous solutions
  4240. with open(filename, "a") as file:
  4241.  
  4242. for action in total_action_list:
  4243.  
  4244. file.write(action + "\n")
  4245. file.write("-----\n")
  4246.  
  4247.  
  4248. #### Bomb and Smoke are both unloaded
  4249. elif Grabbable_Dict_Copy[pot][0][2] == '1':
  4250.  
  4251. action_list001 = []
  4252.  
  4253. # COPY STATE
  4254. #######################################################
  4255. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4256. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4257.  
  4258. room_copy_dict_SS = {}
  4259. for room in Room_List_Copy_SS:
  4260. room_copy_dict_SS[room.number] = room
  4261.  
  4262. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4263.  
  4264. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4265. #######################################################
  4266.  
  4267. # Do not allocate anything
  4268. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  4269.  
  4270. # The room we superslide into through the plane corresponding to the given pot
  4271. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4272.  
  4273. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4274.  
  4275. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4276. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4277.  
  4278. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4279. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4280.  
  4281. """
  4282.  
  4283. Now we check all neighbors of our current room (destination_room) and for
  4284. each neighbor that has a chest or deku guard in it, we will create a copy
  4285. of our copy of the state, then enter each of them through each possible
  4286. loading plane and then check the chest/guard addresses and see if anything
  4287. lines up
  4288.  
  4289. """
  4290.  
  4291. for bordering_room in Neighbors(destination_room, Room_List):
  4292.  
  4293. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4294.  
  4295. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4296.  
  4297. # COPY STATE
  4298. #######################################################
  4299. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4300. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4301.  
  4302. room_copy_dict_2 = {}
  4303. for room in Room_List_Copy_2:
  4304. room_copy_dict_2[room.number] = room
  4305.  
  4306. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4307.  
  4308. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4309. #######################################################
  4310.  
  4311. action_list_2 = []
  4312.  
  4313. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4314.  
  4315. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4316.  
  4317. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4318. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4319.  
  4320.  
  4321. ##### Now check for chests/deku guards
  4322.  
  4323. chest_guard_list = []
  4324.  
  4325. for entry in Heap_Copy_2:
  4326.  
  4327. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4328. chest_guard_list.append(entry)
  4329.  
  4330. soln_found = False
  4331. for entry in chest_guard_list:
  4332. if (pot.address - entry.address) in Offset_List:
  4333.  
  4334. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4335.  
  4336. if (pot.address - entry.address) == 0x160:
  4337. angle_solution_count += 1
  4338. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4339. elif (pot.address - entry.address) == 0x1F0:
  4340. position_solution_count += 1
  4341. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4342.  
  4343. soln_found = True
  4344.  
  4345. if soln_found is True:
  4346. total_action_list = action_list + action_list_transition + action_list001 + action_list_2
  4347.  
  4348. # the "a" argument is important so we don't overwrite previous solutions
  4349. with open(filename, "a") as file:
  4350.  
  4351. for action in total_action_list:
  4352.  
  4353. file.write(action + "\n")
  4354. file.write("-----\n")
  4355.  
  4356.  
  4357.  
  4358. # If there isn't a chest/guard, superslide (into chest/guard room by assumption), then exit then reenter it (this case never happens in palace, so this is an okay assumption)
  4359. elif Chest_In_Room(neighbor) == False and Deku_Guard_In_Room(neighbor) == False:
  4360.  
  4361. for pot in valid_pot_list:
  4362.  
  4363. # both bomb and smoke loaded on superslide
  4364. if Grabbable_Dict_Copy[pot][0][0] == '1':
  4365.  
  4366. action_list100 = []
  4367.  
  4368. # COPY STATE
  4369. #######################################################
  4370. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  4371. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4372.  
  4373. room_copy_dict_2 = {}
  4374. for room in Room_List_Copy_2:
  4375. room_copy_dict_2[room.number] = room
  4376.  
  4377. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4378.  
  4379. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  4380. #######################################################
  4381.  
  4382. Bomb_And_Smoke_Superslide(Heap_Copy_2, neighbor_copy.number, Overlay_Dict_Copy_2)
  4383. action_list100.append("Superslide with Bomb and Smoke still allocated")
  4384.  
  4385. # The room we superslide into through the plane corresponding to the given pot
  4386. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4387.  
  4388. destination_room_copy = room_copy_dict_2[destination_room.number]
  4389. neighbor_copy_2 = room_copy_dict_2[neighbor_copy.number]
  4390.  
  4391. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  4392. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  4393.  
  4394. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4395. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4396.  
  4397. # Now exit the chest room
  4398. Load_Room(Heap_Copy_2, neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  4399. action_list100.append("Load Room: Room %d" %(neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4400.  
  4401. # Now reenter the chest room
  4402. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4403. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4404.  
  4405. ##### Now check for chests/deku guards
  4406.  
  4407. chest_guard_list = []
  4408.  
  4409. for entry in Heap_Copy_2:
  4410.  
  4411. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4412. chest_guard_list.append(entry)
  4413.  
  4414. soln_found = False
  4415. for entry in chest_guard_list:
  4416. if (pot.address - entry.address) in Offset_List:
  4417.  
  4418. action_list100.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4419.  
  4420. if (pot.address - entry.address) == 0x160:
  4421. angle_solution_count += 1
  4422. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4423. elif (pot.address - entry.address) == 0x1F0:
  4424. position_solution_count += 1
  4425. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4426.  
  4427. soln_found = True
  4428.  
  4429. if soln_found is True:
  4430. total_action_list = action_list + action_list_transition + action_list100
  4431.  
  4432. # the "a" argument is important so we don't overwrite previous solutions
  4433. with open(filename, "a") as file:
  4434.  
  4435. for action in total_action_list:
  4436.  
  4437. file.write(action + "\n")
  4438. file.write("-----\n")
  4439.  
  4440.  
  4441.  
  4442. ##### Only smoke is loaded from superslide
  4443. elif Grabbable_Dict_Copy[pot][0][1] == '1':
  4444.  
  4445. action_list010 = []
  4446.  
  4447. # COPY STATE
  4448. #######################################################
  4449. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  4450. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4451.  
  4452. room_copy_dict_2 = {}
  4453. for room in Room_List_Copy_2:
  4454. room_copy_dict_2[room.number] = room
  4455.  
  4456. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4457.  
  4458. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  4459. #######################################################
  4460.  
  4461. Allocate_Smoke(Heap_Copy_2, neighbor_copy.number, Overlay_Dict_Copy_2)
  4462. action_list010.append("Superslide with Smoke still allocated")
  4463.  
  4464. # The room we superslide into through the plane corresponding to the given pot
  4465. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4466.  
  4467. destination_room_copy = room_copy_dict_2[destination_room.number]
  4468. neighbor_copy_2 = room_copy_dict_2[neighbor_copy.number]
  4469.  
  4470. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  4471. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  4472.  
  4473. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4474. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4475.  
  4476. # Now exit the chest room
  4477. Load_Room(Heap_Copy_2, neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  4478. action_list010.append("Load Room: Room %d" %(neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4479.  
  4480. # Now reenter the chest room
  4481. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4482. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4483.  
  4484. ##### Now check for chests/deku guards
  4485.  
  4486. chest_guard_list = []
  4487.  
  4488. for entry in Heap_Copy_2:
  4489.  
  4490. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4491. chest_guard_list.append(entry)
  4492.  
  4493. soln_found = False
  4494. for entry in chest_guard_list:
  4495. if (pot.address - entry.address) in Offset_List:
  4496.  
  4497. action_list010.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4498.  
  4499. if (pot.address - entry.address) == 0x160:
  4500. angle_solution_count += 1
  4501. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4502. elif (pot.address - entry.address) == 0x1F0:
  4503. position_solution_count += 1
  4504. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4505.  
  4506. soln_found = True
  4507.  
  4508. if soln_found is True:
  4509. total_action_list = action_list + action_list_transition + action_list010
  4510.  
  4511. # the "a" argument is important so we don't overwrite previous solutions
  4512. with open(filename, "a") as file:
  4513.  
  4514. for action in total_action_list:
  4515.  
  4516. file.write(action + "\n")
  4517. file.write("-----\n")
  4518.  
  4519.  
  4520.  
  4521. #### Bomb and Smoke are both unloaded
  4522. elif Grabbable_Dict_Copy[pot][0][2] == '1':
  4523.  
  4524. action_list001 = []
  4525.  
  4526. # COPY STATE
  4527. #######################################################
  4528. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  4529. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4530.  
  4531. room_copy_dict_2 = {}
  4532. for room in Room_List_Copy_2:
  4533. room_copy_dict_2[room.number] = room
  4534.  
  4535. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4536.  
  4537. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  4538. #######################################################
  4539.  
  4540. # Do not allocate anything
  4541. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  4542.  
  4543. # The room we superslide into through the plane corresponding to the given pot
  4544. destination_room = Current_Room([neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4545.  
  4546. destination_room_copy = room_copy_dict_2[destination_room.number]
  4547. neighbor_copy_2 = room_copy_dict_2[neighbor_copy.number]
  4548.  
  4549. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  4550. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  4551.  
  4552. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4553. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4554.  
  4555. # Now exit the chest room
  4556. Load_Room(Heap_Copy_2, neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  4557. action_list001.append("Load Room: Room %d" %(neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4558.  
  4559. # Now reenter the chest room
  4560. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  4561. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4562.  
  4563. ##### Now check for chests/deku guards
  4564.  
  4565. chest_guard_list = []
  4566.  
  4567. for entry in Heap_Copy_2:
  4568.  
  4569. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4570. chest_guard_list.append(entry)
  4571.  
  4572. soln_found = False
  4573. for entry in chest_guard_list:
  4574. if (pot.address - entry.address) in Offset_List:
  4575.  
  4576. action_list001.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4577.  
  4578. if (pot.address - entry.address) == 0x160:
  4579. angle_solution_count += 1
  4580. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4581. elif (pot.address - entry.address) == 0x1F0:
  4582. position_solution_count += 1
  4583. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4584.  
  4585. soln_found = True
  4586.  
  4587. if soln_found is True:
  4588. total_action_list = action_list + action_list_transition + action_list001
  4589.  
  4590. # the "a" argument is important so we don't overwrite previous solutions
  4591. with open(filename, "a") as file:
  4592.  
  4593. for action in total_action_list:
  4594.  
  4595. file.write(action + "\n")
  4596. file.write("-----\n")
  4597.  
  4598.  
  4599. ##### No valid grabbable actor in neighbor
  4600. elif neighbor not in valid_grabbable_actor_room_list:
  4601.  
  4602. for new_neighbor in Neighbors(neighbor, Room_List):
  4603.  
  4604. # if new neighbor has a valid grabbable actor... (Otherwise, we do nothing)
  4605. if new_neighbor in valid_grabbable_actor_room_list:
  4606.  
  4607.  
  4608. for neighbor_transition in Shared_Transitions(current_room, neighbor):
  4609. for new_neighbor_transition in Shared_Transitions(neighbor, new_neighbor):
  4610.  
  4611. action_list_transition = []
  4612.  
  4613. ##### COPY THE STATE
  4614. #######################################################
  4615. Room_List_Copy = Copy_Room_List(Room_List)
  4616. Overlay_Dict_Copy = Copy_Overlay_Dict(Overlay_Dict)
  4617.  
  4618. room_copy_dict = {}
  4619. for room in Room_List_Copy:
  4620. room_copy_dict[room.number] = room
  4621.  
  4622. Heap_Copy = Copy_Heap(Heap, Room_List_Copy, Overlay_Dict_Copy)
  4623.  
  4624. Grabbable_Dict_Copy = Copy_Grabbable_Dict(Grabbable_Dict, Room_List_Copy)
  4625. #######################################################
  4626.  
  4627. neighbor_copy = room_copy_dict[neighbor.number]
  4628. neighbor_transition_copy = Find_Actor_Copy(neighbor_transition, Room_List_Copy)
  4629.  
  4630. new_neighbor_copy = room_copy_dict[new_neighbor.number]
  4631. new_neighbor_transition_copy = Find_Actor_Copy(new_neighbor_transition, Room_List_Copy)
  4632.  
  4633. ##### ENTER neighbor
  4634.  
  4635. Load_Room(Heap_Copy, neighbor_copy, neighbor_transition_copy, Overlay_Dict_Copy)
  4636. action_list_transition.append("Load Room: Room %d" %(neighbor_copy.number) + " with " + neighbor_transition_copy.name + " %d" %(neighbor_transition_copy.priority))
  4637.  
  4638. ##### ENTER new_neighbor
  4639.  
  4640. Load_Room(Heap_Copy, new_neighbor_copy, new_neighbor_transition_copy, Overlay_Dict_Copy)
  4641. action_list_transition.append("Load Room: Room %d" %(new_neighbor_copy.number) + " with " + new_neighbor_transition_copy.name + " %d" %(new_neighbor_transition_copy.priority))
  4642.  
  4643.  
  4644. ##### Iterate through all pots in this room
  4645.  
  4646. valid_pot_list = []
  4647. pot_address_list = []
  4648.  
  4649. for pot in Grabbable_Dict_Copy:
  4650.  
  4651. if Actor_Is_In_Room(new_neighbor_copy, pot) is True:
  4652. valid_pot_list.append(pot)
  4653. pot_address_list.append(pot.address)
  4654.  
  4655. # If there is a chest/guard, superslide, then check neighbors for chests/guards and test all (copy state)
  4656. if Chest_In_Room(new_neighbor) == True or Deku_Guard_In_Room(new_neighbor) == True:
  4657.  
  4658. for pot in valid_pot_list:
  4659.  
  4660. # both bomb and smoke loaded on superslide
  4661. if Grabbable_Dict_Copy[pot][0][0] == '1':
  4662.  
  4663. action_list100 = []
  4664.  
  4665. # COPY STATE
  4666. #######################################################
  4667. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4668. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4669.  
  4670. room_copy_dict_SS = {}
  4671. for room in Room_List_Copy_SS:
  4672. room_copy_dict_SS[room.number] = room
  4673.  
  4674. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4675.  
  4676. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4677. #######################################################
  4678.  
  4679. Bomb_And_Smoke_Superslide(Heap_Copy_SS, new_neighbor.number, Overlay_Dict_Copy_SS)
  4680. action_list100.append("Superslide with Bomb and Smoke still allocated")
  4681.  
  4682. # The room we superslide into through the plane corresponding to the given pot
  4683. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4684.  
  4685. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4686.  
  4687. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4688. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4689.  
  4690. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4691. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4692.  
  4693. """
  4694.  
  4695. Now we check all neighbors of our current room (destination_room) and for
  4696. each neighbor that has a chest or deku guard in it, we will create a copy
  4697. of our copy of the state, then enter each of them through each possible
  4698. loading plane and then check the chest/guard addresses and see if anything
  4699. lines up
  4700.  
  4701. """
  4702.  
  4703. for bordering_room in Neighbors(destination_room, Room_List):
  4704.  
  4705. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4706.  
  4707. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4708.  
  4709. # COPY STATE
  4710. #######################################################
  4711. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4712. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4713.  
  4714. room_copy_dict_2 = {}
  4715. for room in Room_List_Copy_2:
  4716. room_copy_dict_2[room.number] = room
  4717.  
  4718. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4719.  
  4720. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4721. #######################################################
  4722.  
  4723. action_list_2 = []
  4724.  
  4725. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4726.  
  4727. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4728.  
  4729. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4730. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4731.  
  4732.  
  4733. ##### Now check for chests/deku guards
  4734.  
  4735. chest_guard_list = []
  4736.  
  4737. for entry in Heap_Copy_2:
  4738.  
  4739. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4740. chest_guard_list.append(entry)
  4741.  
  4742. soln_found = False
  4743. for entry in chest_guard_list:
  4744. if (pot.address - entry.address) in Offset_List:
  4745.  
  4746. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4747.  
  4748. if (pot.address - entry.address) == 0x160:
  4749. angle_solution_count += 1
  4750. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4751. elif (pot.address - entry.address) == 0x1F0:
  4752. position_solution_count += 1
  4753. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4754.  
  4755. soln_found = True
  4756.  
  4757. if soln_found is True:
  4758. total_action_list = action_list + action_list_transition + action_list100 + action_list_2
  4759.  
  4760. # the "a" argument is important so we don't overwrite previous solutions
  4761. with open(filename, "a") as file:
  4762.  
  4763. for action in total_action_list:
  4764.  
  4765. file.write(action + "\n")
  4766. file.write("-----\n")
  4767.  
  4768.  
  4769.  
  4770. ##### Only smoke is loaded from superslide
  4771. elif Grabbable_Dict_Copy[pot][0][1] == '1':
  4772.  
  4773. action_list010 = []
  4774.  
  4775. # COPY STATE
  4776. #######################################################
  4777. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4778. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4779.  
  4780. room_copy_dict_SS = {}
  4781. for room in Room_List_Copy_SS:
  4782. room_copy_dict_SS[room.number] = room
  4783.  
  4784. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4785.  
  4786. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4787. #######################################################
  4788.  
  4789. Allocate_Smoke(Heap_Copy_SS, new_neighbor.number, Overlay_Dict_Copy_SS)
  4790. action_list010.append("Superslide with Smoke still allocated")
  4791.  
  4792. # The room we superslide into through the plane corresponding to the given pot
  4793. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4794.  
  4795. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4796.  
  4797. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4798. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4799.  
  4800. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4801. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4802.  
  4803. """
  4804.  
  4805. Now we check all neighbors of our current room (destination_room) and for
  4806. each neighbor that has a chest or deku guard in it, we will create a copy
  4807. of our copy of the state, then enter each of them through each possible
  4808. loading plane and then check the chest/guard addresses and see if anything
  4809. lines up
  4810.  
  4811. """
  4812.  
  4813. for bordering_room in Neighbors(destination_room, Room_List):
  4814.  
  4815. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4816.  
  4817. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4818.  
  4819. # COPY STATE
  4820. #######################################################
  4821. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4822. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4823.  
  4824. room_copy_dict_2 = {}
  4825. for room in Room_List_Copy_2:
  4826. room_copy_dict_2[room.number] = room
  4827.  
  4828. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4829.  
  4830. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4831. #######################################################
  4832.  
  4833. action_list_2 = []
  4834.  
  4835. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4836.  
  4837. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4838.  
  4839. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4840. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4841.  
  4842.  
  4843. ##### Now check for chests/deku guards
  4844.  
  4845. chest_guard_list = []
  4846.  
  4847. for entry in Heap_Copy_2:
  4848.  
  4849. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4850. chest_guard_list.append(entry)
  4851.  
  4852. soln_found = False
  4853. for entry in chest_guard_list:
  4854. if (pot.address - entry.address) in Offset_List:
  4855.  
  4856. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4857.  
  4858. if (pot.address - entry.address) == 0x160:
  4859. angle_solution_count += 1
  4860. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4861. elif (pot.address - entry.address) == 0x1F0:
  4862. position_solution_count += 1
  4863. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4864.  
  4865. soln_found = True
  4866.  
  4867. if soln_found is True:
  4868. total_action_list = action_list + action_list_transition + action_list010 + action_list_2
  4869.  
  4870. # the "a" argument is important so we don't overwrite previous solutions
  4871. with open(filename, "a") as file:
  4872.  
  4873. for action in total_action_list:
  4874.  
  4875. file.write(action + "\n")
  4876. file.write("-----\n")
  4877.  
  4878.  
  4879. #### Bomb and Smoke are both unloaded
  4880. elif Grabbable_Dict_Copy[pot][0][2] == '1':
  4881.  
  4882. action_list001 = []
  4883.  
  4884. # COPY STATE
  4885. #######################################################
  4886. Room_List_Copy_SS = Copy_Room_List(Room_List_Copy)
  4887. Overlay_Dict_Copy_SS = Copy_Overlay_Dict(Overlay_Dict_Copy)
  4888.  
  4889. room_copy_dict_SS = {}
  4890. for room in Room_List_Copy_SS:
  4891. room_copy_dict_SS[room.number] = room
  4892.  
  4893. Heap_Copy_SS = Copy_Heap(Heap_Copy, Room_List_Copy_SS, Overlay_Dict_Copy_SS)
  4894.  
  4895. Grabbable_Dict_Copy_SS = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_SS)
  4896. #######################################################
  4897.  
  4898. # Do not allocate anything
  4899. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  4900.  
  4901. # The room we superslide into through the plane corresponding to the given pot
  4902. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  4903.  
  4904. destination_room_copy = room_copy_dict_SS[destination_room.number]
  4905.  
  4906. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_SS)
  4907. superslide_transition_copy = Grabbable_Dict_Copy_SS[pot_copy][1]
  4908.  
  4909. Load_Room(Heap_Copy_SS, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_SS)
  4910. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  4911.  
  4912. """
  4913.  
  4914. Now we check all neighbors of our current room (destination_room) and for
  4915. each neighbor that has a chest or deku guard in it, we will create a copy
  4916. of our copy of the state, then enter each of them through each possible
  4917. loading plane and then check the chest/guard addresses and see if anything
  4918. lines up
  4919.  
  4920. """
  4921.  
  4922. for bordering_room in Neighbors(destination_room, Room_List):
  4923.  
  4924. if Chest_In_Room(bordering_room) == True or Deku_Guard_In_Room(bordering_room) == True:
  4925.  
  4926. for loading_plane in Shared_Transitions(destination_room, bordering_room):
  4927.  
  4928. # COPY STATE
  4929. #######################################################
  4930. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy_SS)
  4931. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy_SS)
  4932.  
  4933. room_copy_dict_2 = {}
  4934. for room in Room_List_Copy_2:
  4935. room_copy_dict_2[room.number] = room
  4936.  
  4937. Heap_Copy_2 = Copy_Heap(Heap_Copy_SS, Room_List_Copy_2, Overlay_Dict_Copy_2)
  4938.  
  4939. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy_SS, Room_List_Copy_2)
  4940. #######################################################
  4941.  
  4942. action_list_2 = []
  4943.  
  4944. loading_plane_copy = Find_Actor_Copy(loading_plane, Room_List_Copy_2)
  4945.  
  4946. bordering_room_copy = room_copy_dict_2[bordering_room.number]
  4947.  
  4948. Load_Room(Heap_Copy_2, bordering_room_copy, loading_plane_copy, Overlay_Dict_Copy_2)
  4949. action_list_2.append("Load Room: Room %d" %(bordering_room_copy.number) + " with " + loading_plane_copy.name + " %d" %(loading_plane_copy.priority))
  4950.  
  4951.  
  4952. ##### Now check for chests/deku guards
  4953.  
  4954. chest_guard_list = []
  4955.  
  4956. for entry in Heap_Copy_2:
  4957.  
  4958. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  4959. chest_guard_list.append(entry)
  4960.  
  4961. soln_found = False
  4962. for entry in chest_guard_list:
  4963. if (pot.address - entry.address) in Offset_List:
  4964.  
  4965. action_list_2.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  4966.  
  4967. if (pot.address - entry.address) == 0x160:
  4968. angle_solution_count += 1
  4969. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4970. elif (pot.address - entry.address) == 0x1F0:
  4971. position_solution_count += 1
  4972. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  4973.  
  4974. soln_found = True
  4975.  
  4976. if soln_found is True:
  4977. total_action_list = action_list + action_list_transition + action_list001 + action_list_2
  4978.  
  4979. # the "a" argument is important so we don't overwrite previous solutions
  4980. with open(filename, "a") as file:
  4981.  
  4982. for action in total_action_list:
  4983.  
  4984. file.write(action + "\n")
  4985. file.write("-----\n")
  4986.  
  4987.  
  4988.  
  4989. # If there isn't a chest/guard, superslide (into chest/guard room by assumption), then exit then reenter it (this case never happens in palace, so this is an okay assumption)
  4990. elif Chest_In_Room(new_neighbor) == False and Deku_Guard_In_Room(new_neighbor) == False:
  4991.  
  4992. for pot in valid_pot_list:
  4993.  
  4994. # both bomb and smoke loaded on superslide
  4995. if Grabbable_Dict_Copy[pot][0][0] == '1':
  4996.  
  4997. action_list100 = []
  4998.  
  4999. # COPY STATE
  5000. #######################################################
  5001. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  5002. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  5003.  
  5004. room_copy_dict_2 = {}
  5005. for room in Room_List_Copy_2:
  5006. room_copy_dict_2[room.number] = room
  5007.  
  5008. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  5009.  
  5010. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  5011. #######################################################
  5012.  
  5013. Bomb_And_Smoke_Superslide(Heap_Copy_2, new_neighbor_copy.number, Overlay_Dict_Copy_2)
  5014. action_list100.append("Superslide with Bomb and Smoke still allocated")
  5015.  
  5016. # The room we superslide into through the plane corresponding to the given pot
  5017. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  5018.  
  5019. destination_room_copy = room_copy_dict_2[destination_room.number]
  5020. new_neighbor_copy_2 = room_copy_dict_2[new_neighbor_copy.number]
  5021.  
  5022. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  5023. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  5024.  
  5025. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5026. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5027.  
  5028. # Now exit the chest room
  5029. Load_Room(Heap_Copy_2, new_neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  5030. action_list100.append("Load Room: Room %d" %(new_neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5031.  
  5032. # Now reenter the chest room
  5033. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5034. action_list100.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5035.  
  5036. ##### Now check for chests/deku guards
  5037.  
  5038. chest_guard_list = []
  5039.  
  5040. for entry in Heap_Copy_2:
  5041.  
  5042. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  5043. chest_guard_list.append(entry)
  5044.  
  5045. soln_found = False
  5046. for entry in chest_guard_list:
  5047. if (pot.address - entry.address) in Offset_List:
  5048.  
  5049. action_list100.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  5050.  
  5051. if (pot.address - entry.address) == 0x160:
  5052. angle_solution_count += 1
  5053. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5054. elif (pot.address - entry.address) == 0x1F0:
  5055. position_solution_count += 1
  5056. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5057.  
  5058. soln_found = True
  5059.  
  5060. if soln_found is True:
  5061. total_action_list = action_list + action_list_transition + action_list100
  5062.  
  5063. # the "a" argument is important so we don't overwrite previous solutions
  5064. with open(filename, "a") as file:
  5065.  
  5066. for action in total_action_list:
  5067.  
  5068. file.write(action + "\n")
  5069. file.write("-----\n")
  5070.  
  5071.  
  5072.  
  5073. ##### Only smoke is loaded from superslide
  5074. elif Grabbable_Dict_Copy[pot][0][1] == '1':
  5075.  
  5076. action_list010 = []
  5077.  
  5078. # COPY STATE
  5079. #######################################################
  5080. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  5081. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  5082.  
  5083. room_copy_dict_2 = {}
  5084. for room in Room_List_Copy_2:
  5085. room_copy_dict_2[room.number] = room
  5086.  
  5087. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  5088.  
  5089. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  5090. #######################################################
  5091.  
  5092. Allocate_Smoke(Heap_Copy_2, new_neighbor_copy.number, Overlay_Dict_Copy_2)
  5093. action_list010.append("Superslide with Smoke still allocated")
  5094.  
  5095. # The room we superslide into through the plane corresponding to the given pot
  5096. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  5097.  
  5098. destination_room_copy = room_copy_dict_2[destination_room.number]
  5099. new_neighbor_copy_2 = room_copy_dict_2[new_neighbor_copy.number]
  5100.  
  5101. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  5102. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  5103.  
  5104. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5105. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5106.  
  5107. # Now exit the chest room
  5108. Load_Room(Heap_Copy_2, new_neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  5109. action_list010.append("Load Room: Room %d" %(new_neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5110.  
  5111. # Now reenter the chest room
  5112. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5113. action_list010.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5114.  
  5115. ##### Now check for chests/deku guards
  5116.  
  5117. chest_guard_list = []
  5118.  
  5119. for entry in Heap_Copy_2:
  5120.  
  5121. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  5122. chest_guard_list.append(entry)
  5123.  
  5124. soln_found = False
  5125. for entry in chest_guard_list:
  5126. if (pot.address - entry.address) in Offset_List:
  5127.  
  5128. action_list010.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  5129.  
  5130. if (pot.address - entry.address) == 0x160:
  5131. angle_solution_count += 1
  5132. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5133. elif (pot.address - entry.address) == 0x1F0:
  5134. position_solution_count += 1
  5135. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5136.  
  5137. soln_found = True
  5138.  
  5139. if soln_found is True:
  5140. total_action_list = action_list + action_list_transition + action_list010
  5141.  
  5142. # the "a" argument is important so we don't overwrite previous solutions
  5143. with open(filename, "a") as file:
  5144.  
  5145. for action in total_action_list:
  5146.  
  5147. file.write(action + "\n")
  5148. file.write("-----\n")
  5149.  
  5150.  
  5151.  
  5152. #### Bomb and Smoke are both unloaded
  5153. elif Grabbable_Dict_Copy[pot][0][2] == '1':
  5154.  
  5155. action_list001 = []
  5156.  
  5157. # COPY STATE
  5158. #######################################################
  5159. Room_List_Copy_2 = Copy_Room_List(Room_List_Copy)
  5160. Overlay_Dict_Copy_2 = Copy_Overlay_Dict(Overlay_Dict_Copy)
  5161.  
  5162. room_copy_dict_2 = {}
  5163. for room in Room_List_Copy_2:
  5164. room_copy_dict_2[room.number] = room
  5165.  
  5166. Heap_Copy_2 = Copy_Heap(Heap_Copy, Room_List_Copy_2, Overlay_Dict_Copy_2)
  5167.  
  5168. Grabbable_Dict_Copy_2 = Copy_Grabbable_Dict(Grabbable_Dict_Copy, Room_List_Copy_2)
  5169. #######################################################
  5170.  
  5171. # Do not allocate anything
  5172. action_list001.append("Superslide with Bomb and Smoke unloaded when passing plane")
  5173.  
  5174. # The room we superslide into through the plane corresponding to the given pot
  5175. destination_room = Current_Room([new_neighbor_copy, Grabbable_Dict_Copy[pot][1]], Room_List_Copy)
  5176.  
  5177. destination_room_copy = room_copy_dict_2[destination_room.number]
  5178. new_neighbor_copy_2 = room_copy_dict_2[new_neighbor_copy.number]
  5179.  
  5180. pot_copy = Find_Actor_Copy(pot, Room_List_Copy_2)
  5181. superslide_transition_copy = Grabbable_Dict_Copy_2[pot_copy][1]
  5182.  
  5183. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5184. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5185.  
  5186. # Now exit the chest room
  5187. Load_Room(Heap_Copy_2, new_neighbor_copy_2, superslide_transition_copy, Overlay_Dict_Copy_2)
  5188. action_list001.append("Load Room: Room %d" %(new_neighbor_copy_2.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5189.  
  5190. # Now reenter the chest room
  5191. Load_Room(Heap_Copy_2, destination_room_copy, superslide_transition_copy, Overlay_Dict_Copy_2)
  5192. action_list001.append("Load Room: Room %d" %(destination_room_copy.number) + " with " + superslide_transition_copy.name + " %d" %(superslide_transition_copy.priority))
  5193.  
  5194. ##### Now check for chests/deku guards
  5195.  
  5196. chest_guard_list = []
  5197.  
  5198. for entry in Heap_Copy_2:
  5199.  
  5200. if type(entry) == Actor and (entry.Id == '0006' or entry.Id == '017A'):
  5201. chest_guard_list.append(entry)
  5202.  
  5203. soln_found = False
  5204. for entry in chest_guard_list:
  5205. if (pot.address - entry.address) in Offset_List:
  5206.  
  5207. action_list001.append("SOLUTION: " + pot.name + " (Priority %d)" %(pot.priority) + " from Room %d" %(pot.room_number) + " lines up with " + entry.name + " (Priority %d)" %(entry.priority) + " from Room %d" %(entry.room_number) + " with offset: " + hex(pot.address - entry.address))
  5208.  
  5209. if (pot.address - entry.address) == 0x160:
  5210. angle_solution_count += 1
  5211. print("ANGLE SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5212. elif (pot.address - entry.address) == 0x1F0:
  5213. position_solution_count += 1
  5214. print("Z POSITION SOLUTION FOUND (CHEST)!!!!!!!!!!!")
  5215.  
  5216. soln_found = True
  5217.  
  5218. if soln_found is True:
  5219. total_action_list = action_list + action_list_transition + action_list001
  5220.  
  5221. # the "a" argument is important so we don't overwrite previous solutions
  5222. with open(filename, "a") as file:
  5223.  
  5224. for action in total_action_list:
  5225.  
  5226. file.write(action + "\n")
  5227. file.write("-----\n")
  5228.  
  5229.  
  5230.  
  5231.  
  5232. ###############################################################################
  5233. ###############################################################################
  5234. ###############################################################################
  5235. ###############################################################################
  5236. ###############################################################################
  5237. ###############################################################################
  5238. ###############################################################################
  5239. ###############################################################################
  5240. ###############################################################################
  5241. ###############################################################################
  5242. ###############################################################################
  5243. ###############################################################################
  5244. ###############################################################################
  5245. ###############################################################################
  5246. ###############################################################################
  5247. ###############################################################################
  5248. ###############################################################################
  5249. ###############################################################################
  5250. ###############################################################################
  5251. ###############################################################################
  5252. ###############################################################################
  5253. ###############################################################################
  5254. ###############################################################################
  5255. ###############################################################################
  5256. ###############################################################################
  5257. ###############################################################################
  5258. ###############################################################################
  5259. ###############################################################################
  5260. ###############################################################################
  5261. ###############################################################################
  5262. ###############################################################################
  5263. ###############################################################################
  5264. ###############################################################################
  5265. ###############################################################################
  5266. ###############################################################################
  5267. ###############################################################################
  5268. ###############################################################################
  5269. ###############################################################################
  5270. ###############################################################################
  5271. ###############################################################################
  5272. ###############################################################################
  5273. ###############################################################################
  5274. ###############################################################################
  5275. ###############################################################################
  5276. ###############################################################################
  5277. ###############################################################################
  5278. ###############################################################################
  5279. ###############################################################################
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287. """
  5288.  
  5289. Before proceeding, we should define all of the transitions we plan on passing through
  5290.  
  5291. Since "Beneath the Graveyard" is relatively simple and I currently only want to consider
  5292. passing through a single plane, I will just define Plane_1 to be the plane shared between
  5293. Room0 and Room1
  5294.  
  5295. This loading plane happens the be the second element in Room0_queue, so I will define it based on that
  5296.  
  5297. """
  5298.  
  5299. Oceanside_Plane_0 = Oceanside_Room3_queue[0]
  5300.  
  5301.  
  5302.  
  5303. Palace_Plane_0 = Palace_Room0_queue[0]
  5304.  
  5305. """
  5306.  
  5307. Grabbable_dict is a dictionary of the grabbable actors (such as pots) that
  5308. we want to attempt to use for superslide SRM where the keys are the grabbable
  5309. actors and the values are lists with 3-bit strings where each bit means:
  5310.  
  5311. 100 : Possible to enter Plane with both Bomb and Smoke loaded
  5312. 010 : Possible to enter Plane with Smoke loaded, but no Bomb loaded
  5313. 001 : Possible to enter Plane with no Smoke loaded
  5314.  
  5315. and Transitions, where the transitions are the ones you can superslide through
  5316.  
  5317.  
  5318. """
  5319.  
  5320. Oceanside_Grabbable_dict = {
  5321. Oceanside_Room3_queue[6] : ['010', Oceanside_Plane_0],
  5322. Oceanside_Room3_queue[7] : ['010', Oceanside_Plane_0]
  5323. }
  5324.  
  5325. Palace_Grabbable_dict = {
  5326. Palace_Room1_queue[18] : ['010', Palace_Plane_0]
  5327. }
  5328.  
  5329.  
  5330. Hardcoded_Allocation_List_0 = [
  5331. 'Fish',
  5332. 'Fish',
  5333. 'Bugs',
  5334. 'Bugs',
  5335. 'Smoke',
  5336. 'Chu',
  5337. 'Chu',
  5338. 'Chu',
  5339. 'Arrow',
  5340. 'Arrow',
  5341. 'Arrow',
  5342. 'Arrow',
  5343. 'Arrow',
  5344. 'Bomb',
  5345. 'Bomb',
  5346. 'Bomb',
  5347. 'Zora Fins',
  5348. 'Hookshot',
  5349. 'Charged Spin Attack'
  5350. ]
  5351.  
  5352. Hardcoded_Allocation_List_2 = [
  5353. 'Smoke',
  5354. 'Arrow',
  5355. 'Arrow',
  5356. 'Arrow',
  5357. 'Arrow',
  5358. 'Arrow',
  5359. 'Bomb',
  5360. 'Bomb',
  5361. 'Bomb',
  5362. 'Hookshot',
  5363. 'Charged Spin Attack'
  5364. ]
  5365.  
  5366. Hardcoded_Allocation_List_2_G = [
  5367. 'Gold Skulltula'
  5368. 'Smoke',
  5369. 'Arrow',
  5370. 'Arrow',
  5371. 'Arrow',
  5372. 'Arrow',
  5373. 'Arrow',
  5374. 'Bomb',
  5375. 'Bomb',
  5376. 'Bomb',
  5377. 'Hookshot',
  5378. 'Charged Spin Attack'
  5379. ]
  5380.  
  5381. Hardcoded_Allocation_List_3 = [
  5382. 'Bomb',
  5383. 'Bomb',
  5384. 'Bomb',
  5385. 'Hookshot',
  5386. 'Charged Spin Attack'
  5387. ]
  5388.  
  5389. Hardcoded_Allocation_List_4 = [
  5390. 'Arrow',
  5391. 'Arrow',
  5392. 'Arrow',
  5393. 'Arrow',
  5394. 'Arrow',
  5395. 'Bomb',
  5396. 'Bomb',
  5397. 'Bomb',
  5398. 'Hookshot',
  5399. 'Charged Spin Attack'
  5400. ]
  5401.  
  5402.  
  5403.  
  5404.  
  5405. Allocation_List_0 = [
  5406. 'Fish',
  5407. 'Smoke',
  5408. 'Arrow',
  5409. 'Arrow',
  5410. 'Arrow',
  5411. 'Bomb',
  5412. 'Bomb',
  5413. 'Bomb',
  5414. 'Zora Fins',
  5415. 'Hookshot',
  5416. 'Charged Spin Attack'
  5417. ]
  5418.  
  5419. Allocation_List_0_G = [
  5420. 'Gold Skulltula',
  5421. 'Fish',
  5422. 'Smoke',
  5423. 'Arrow',
  5424. 'Arrow',
  5425. 'Arrow',
  5426. 'Bomb',
  5427. 'Bomb',
  5428. 'Bomb',
  5429. 'Zora Fins',
  5430. 'Hookshot',
  5431. 'Charged Spin Attack'
  5432. ]
  5433.  
  5434.  
  5435.  
  5436. Allocation_List_5 = [
  5437. 'Smoke',
  5438. 'Arrow',
  5439. 'Arrow',
  5440. 'Arrow',
  5441. 'Bomb',
  5442. 'Bomb',
  5443. 'Bomb',
  5444. 'Zora Fins',
  5445. 'Hookshot',
  5446. 'Charged Spin Attack'
  5447. ]
  5448.  
  5449. Allocation_List_5_G = [
  5450. 'Gold Skulltula',
  5451. 'Smoke',
  5452. 'Arrow',
  5453. 'Arrow',
  5454. 'Arrow',
  5455. 'Bomb',
  5456. 'Bomb',
  5457. 'Bomb',
  5458. 'Zora Fins',
  5459. 'Hookshot',
  5460. 'Charged Spin Attack'
  5461. ]
  5462.  
  5463. Hardcoded_Allocation_List_4 = [
  5464. 'Arrow',
  5465. 'Hookshot',
  5466. 'Charged Spin Attack'
  5467. ]
  5468.  
  5469. Oceanside_Allocation_List_6 = [
  5470. 'Fish',
  5471. 'Fish'
  5472. 'Smoke',
  5473. 'Chu',
  5474. 'Chu',
  5475. 'Chu',
  5476. 'Arrow',
  5477. 'Arrow',
  5478. 'Arrow',
  5479. 'Arrow',
  5480. 'Arrow',
  5481. 'Bomb',
  5482. 'Bomb',
  5483. 'Bomb',
  5484. 'Hookshot',
  5485. 'Charged Spin Attack'
  5486. ]
  5487.  
  5488. Oceanside_Allocation_List_6_G = [
  5489. 'Gold Skulltula',
  5490. 'Fish',
  5491. 'Fish'
  5492. 'Smoke',
  5493. 'Chu',
  5494. 'Chu',
  5495. 'Chu',
  5496. 'Arrow',
  5497. 'Arrow',
  5498. 'Arrow',
  5499. 'Arrow',
  5500. 'Arrow',
  5501. 'Bomb',
  5502. 'Bomb',
  5503. 'Bomb',
  5504. 'Hookshot',
  5505. 'Charged Spin Attack'
  5506. ]
  5507.  
  5508. Palace_Allocation_List_0_S = [
  5509. 'Square Sign',
  5510. 'Square Sign',
  5511. 'Square Sign',
  5512. 'Square Sign',
  5513. 'Square Sign',
  5514. 'Square Sign',
  5515. 'Square Sign',
  5516. 'Square Sign',
  5517. 'Square Sign',
  5518. 'Bomb',
  5519. 'Bomb',
  5520. 'Bomb',
  5521. 'Hookshot',
  5522. ]
  5523.  
  5524. Palace_Allocation_List_0 = [
  5525. 'Bomb',
  5526. 'Bomb',
  5527. 'Bomb',
  5528. 'Hookshot',
  5529. ]
  5530.  
  5531. Allocation_List_Dict_Grave_0 = {
  5532. 0 : Hardcoded_Allocation_List_3,
  5533. 1 : Hardcoded_Allocation_List_3
  5534. }
  5535.  
  5536. Allocation_List_Dict_Grave_4 = {
  5537. 0 : Hardcoded_Allocation_List_4,
  5538. 1 : Hardcoded_Allocation_List_4
  5539. }
  5540.  
  5541. Allocation_List_Dict_Oceanside_0 = {
  5542. 3 : Hardcoded_Allocation_List_2_G,
  5543. 4 : Hardcoded_Allocation_List_2
  5544. }
  5545.  
  5546. Allocation_List_Dict_Oceanside_1 = {
  5547. 3 : Allocation_List_0_G,
  5548. 4 : Allocation_List_0
  5549. }
  5550.  
  5551. Allocation_List_Dict_Oceanside_5 = {
  5552. 3 : Allocation_List_5_G,
  5553. 4 : Allocation_List_5
  5554. }
  5555.  
  5556. Allocation_List_Dict_Oceanside_6 = {
  5557. 3 : Oceanside_Allocation_List_6_G,
  5558. 4 : Oceanside_Allocation_List_6
  5559. }
  5560.  
  5561. Allocation_List_Dict_Palace_0 = {
  5562. 0 : Palace_Allocation_List_0_S,
  5563. 1 : Palace_Allocation_List_0,
  5564. 2 : Palace_Allocation_List_0
  5565. }
  5566.  
  5567. save_path = "C:\\Users\\xyzabc\\Documents\\Bizhawk RAM Watch\\scripts\\"
  5568. name_of_file = "osh"
  5569. complete_name = save_path + name_of_file + ".txt"
  5570.  
  5571. Heap = [Node(0x40B140, node_size), Node(0x5FFFFF, node_size)]
  5572.  
  5573. ##### OCEANSIDE
  5574. Randomized_Solver(Oceanside_Room3, Oceanside_Room_List, 5, Allocation_List_Dict_Oceanside_6, Oceanside_Grabbable_dict, Overlay_dict, complete_name, [0x160, 0x1F0], Heap)
  5575.  
  5576.  
  5577. ##### BENEATH THE GRAVEYARD
  5578. #Randomized_Solver(Room0, Room_List, 5, Allocation_List_Dict_Grave_4, Grabbable_dict, Overlay_dict, complete_name, [0x160, 0x1F0], Heap)
  5579.  
  5580. ##### DEKU PALACE (not accounting for needing to break a pot)
  5581. #Randomized_Solver(Palace_Room0, Palace_Room_List, 5, Allocation_List_Dict_Palace_0, Palace_Grabbable_dict, Overlay_dict, complete_name, [0x200], Heap)
  5582.  
  5583. """
  5584.  
  5585. SOME ASSUMPTIONS ABOUT THIS SCRIPT:
  5586.  
  5587. - THE SOLVER AUTOMATICALLY CLEARS ALL BAD BATS AT THE START
  5588.  
  5589. - WE DO NOT DEALLOCATE WEBS OR GOLD SKULLTULAS IN OCEANSIDE BECAUSE WE WANT
  5590. A SETUP THAT DOES NOT NEED SONG OF TIME STORAGE TO DO REPEATEDLY. EVEN IF IT
  5591. ALLOWED DEALLOCATIONG GOLD SKULLTULAS, IT DOES NOT ACCOUNT FOR THE TOKENS AND
  5592. IT ASSUMES DEALLOCATING A GOLD SKULLTULA IS EQUIVALENT TO PICKING UP ITS TOKEN
  5593.  
  5594. - WE ASSUME THAT WE ALWAYS PERFORM THE DEALLOCATION STEPS BEFORE THE ALLOCATION
  5595. STEPS BECAUSE IT IS EASIER TO DEAL WITH SOLUTIONS WITH THIS QUALITY
  5596.  
  5597. - THIS SCRIPT HARDCODES HOW WE DEALLOCATE THE 01E7 BONK ACTORS FOR THE OCEANSIDE
  5598. ROOM 3 TABLE
  5599.  
  5600. - ALLOCATING GOLD SKULLTULAS IS SPECIFIC TO ROOM 3 OF OCEANSIDE (SHOOTING THE
  5601. PAINTING ALLOCATES A GOLD SKULLTULA)
  5602.  
  5603. TODO: (DEKU PALACE CONTEXT) WANT A WAY TO ASSERT THAT A POT NEEDS
  5604. TO BREAK BEFORE PALACE SUPERSLIDE FOR ONE OF THE POTS (I THINK; NEEDS TESTING)
  5605.  
  5606. TODO: Load_Room() always assumes that cluster is loaded after the previous room
  5607. deallocates, Load_Room_No_Rupee_Cluster() will load the room but not the rupees
  5608. from the cluster (though it technically still loads the cluster actor 00E8 itself,
  5609. just not the 000E rupees it spawns), and Load_Room_Rupee_Cluster_Before_Previous_Unloads()
  5610. assumes the cluster loads before the previous room deallocates (and this one will only
  5611. apply to graveyard)
  5612.  
  5613.  
  5614.  
  5615. """
  5616.  
  5617. """
  5618. Overlay_Dict = Overlay_dict
  5619. Room_List = Oceanside_Room_List
  5620.  
  5621.  
  5622. Load_Scene(Heap, Room_List[0], Overlay_Dict)
  5623.  
  5624. #Display_Heap(Heap)
  5625.  
  5626. print('***********************************************************************')
  5627. print('***********************************************************************')
  5628. print('***********************************************************************')
  5629.  
  5630.  
  5631. Deallocate(Heap, Room_List[0].priority_queue[2], Overlay_Dict)
  5632. Deallocate(Heap, Room_List[0].priority_queue[5], Overlay_Dict)
  5633. Deallocate(Heap, Room_List[0].priority_queue[6], Overlay_Dict)
  5634. Deallocate(Heap, Room_List[0].priority_queue[7], Overlay_Dict)
  5635. Deallocate(Heap, Room_List[0].priority_queue[15], Overlay_Dict)
  5636. Deallocate(Heap, Room_List[0].priority_queue[17], Overlay_Dict)
  5637. Deallocate(Heap, Room_List[0].priority_queue[19], Overlay_Dict)
  5638.  
  5639. #Display_Heap(Heap)
  5640.  
  5641. print('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD')
  5642.  
  5643. Allocate_Arrow(Heap, 3, Overlay_Dict) # 3 for Room 3
  5644. Allocate_Arrow(Heap, 3, Overlay_Dict) # 3 for Room 3
  5645. Allocate_Bomb(Heap, 3, Overlay_Dict) # 3 for Room 3
  5646. Allocate_Bomb(Heap, 3, Overlay_Dict) # 3 for Room 3
  5647.  
  5648. #Display_Heap(Heap)
  5649.  
  5650. print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5651.  
  5652. Load_Room(Heap, Room_List[1], Room_List[0].priority_queue[0], Overlay_Dict)
  5653.  
  5654. #Display_Heap(Heap)
  5655.  
  5656. print('***********************************************************************')
  5657. print('***********************************************************************')
  5658. print('***********************************************************************')
  5659.  
  5660.  
  5661. Allocate_Smoke(Heap, 4, Overlay_Dict)
  5662. Allocate_Arrow(Heap, 4, Overlay_Dict)
  5663. Allocate_Arrow(Heap, 4, Overlay_Dict)
  5664. Allocate_Arrow(Heap, 4, Overlay_Dict)
  5665. Allocate_Arrow(Heap, 4, Overlay_Dict)
  5666. Allocate_Bomb(Heap, 4, Overlay_Dict)
  5667. Allocate_Bomb(Heap, 4, Overlay_Dict)
  5668. Allocate_Charged_Spin_Attack(Heap, 4, Overlay_Dict)
  5669.  
  5670. Display_Heap(Heap)
  5671.  
  5672. print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5673.  
  5674. Load_Room(Heap, Room_List[0], Room_List[0].priority_queue[0], Overlay_Dict)
  5675.  
  5676. Display_Heap(Heap)
  5677.  
  5678. print('***********************************************************************')
  5679. print('***********************************************************************')
  5680. print('***********************************************************************')
  5681.  
  5682.  
  5683. Deallocate(Heap, Room_List[0].priority_queue[2], Overlay_Dict)
  5684. Deallocate(Heap, Room_List[0].priority_queue[4], Overlay_Dict)
  5685. Deallocate(Heap, Room_List[0].priority_queue[15], Overlay_Dict)
  5686. Deallocate(Heap, Room_List[0].priority_queue[17], Overlay_Dict)
  5687. Deallocate(Heap, Room_List[0].priority_queue[19], Overlay_Dict)
  5688. Deallocate(Heap, Room_List[0].priority_queue[23], Overlay_Dict)
  5689.  
  5690. Display_Heap(Heap)
  5691.  
  5692. print('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD')
  5693.  
  5694. Allocate_Smoke(Heap, 3, Overlay_Dict)
  5695. Allocate_Arrow(Heap, 3, Overlay_Dict)
  5696. Allocate_Arrow(Heap, 3, Overlay_Dict)
  5697.  
  5698. Display_Heap(Heap)
  5699.  
  5700. print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5701.  
  5702. Load_Room(Heap, Room_List[1], Room_List[0].priority_queue[0], Overlay_Dict)
  5703.  
  5704. Display_Heap(Heap)
  5705.  
  5706. print('***********************************************************************')
  5707. print('***********************************************************************')
  5708. print('***********************************************************************')
  5709.  
  5710.  
  5711. Allocate_Smoke(Heap, 4, Overlay_Dict)
  5712. Allocate_Bomb(Heap, 4, Overlay_Dict)
  5713.  
  5714. Display_Heap(Heap)
  5715.  
  5716. print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5717.  
  5718. Load_Room(Heap, Room_List[0], Room_List[0].priority_queue[0], Overlay_Dict)
  5719.  
  5720. Display_Heap(Heap)
  5721.  
  5722. print('***********************************************************************')
  5723. print('***********************************************************************')
  5724. print('***********************************************************************')
  5725.  
  5726. Allocate_Smoke(Heap, 3, Overlay_Dict) # superslide with smoke still allocated
  5727.  
  5728. Display_Heap(Heap)
  5729.  
  5730. print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5731.  
  5732. Load_Room(Heap, Room_List[1], Room_List[0].priority_queue[0], Overlay_Dict)
  5733.  
  5734. Display_Heap(Heap)
  5735.  
  5736. print('***********************************************************************')
  5737. print('***********************************************************************')
  5738. print('***********************************************************************')
  5739.  
  5740.  
  5741. Load_Room(Heap, Room_List[0], Room_List[0].priority_queue[0], Overlay_Dict)
  5742.  
  5743. Display_Heap(Heap)
  5744.  
  5745. print('***********************************************************************')
  5746. print('***********************************************************************')
  5747. print('***********************************************************************')
  5748.  
  5749.  
  5750. Load_Room(Heap, Room_List[1], Room_List[0].priority_queue[0], Overlay_Dict)
  5751.  
  5752.  
  5753. Display_Heap(Heap)
  5754.  
  5755. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement