imbued

SRM Solver 15 (Oceanside and Beneath the Graveyard)

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