Advertisement
imbued

SRM Solver 14 (Oceanside and Beneath Graveyard)

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