set_rule(world.get_entrance('Kings Grave'),lambdastate:state.has_Boots()and(state.can_lift_heavy_rocks()or(state.has_Mirror()andstate.can_reach('West Dark World'))))
set_rule(world.get_entrance('Waterfall of Wishing'),lambdastate:state.has('Flippers'))# can be fake flippered into, but is in weird state inside that might prevent you from doing things. Can be improved in future Todo
set_rule(world.get_entrance('Desert Ledge Return Rocks'),lambdastate:state.can_lift_rocks())# should we decide to place something that is not a dungeon end up there at some point
set_rule(world.get_entrance('Turtle Rock Skull Mirror Spot'),lambdastate:state.has_Mirror()andstate.has('Hammer'))# if stuck, can mirror and hammer the pegs
set_rule(world.get_entrance('Turtle Rock'),lambdastate:state.can_reach('Turtle Rock Open Skull','Entrance'))
set_rule(world.get_entrance('Turtle Rock Skull Reverse'),lambdastate:state.can_reach('Turtle Rock Open Skull','Entrance'))
set_rule(world.get_entrance('Dark World Potion Shop'),lambdastate:state.has_Pearl()and(state.can_lift_rocks()orstate.has('Hammer')orstate.has('Flippers')))
set_rule(world.get_entrance('West Dark World Gap'),lambdastate:state.has_Pearl()andstate.has('Hookshot')and(state.has('Flippers')orstate.has('Hammer')orstate.can_lift_rocks()))
set_rule(world.get_entrance('Palace of Darkness Kiki Door Reverse'),lambdastate:state.can_reach('Palace of Darkness Pay Kiki','Entrance'))# prevent soft lock when coming from behind, not required
set_rule(world.get_entrance('Dark Lake Hylia Drop (East)'),lambdastate:(state.has_Pearl()andstate.has('Flippers')orstate.has_Mirror()))# Overworld Bunny Revival
set_rule(world.get_location('Bombos Tablet'),lambdastate:state.has('Book of Mudora')andstate.has_beam_sword()andstate.has_Mirror())
set_rule(world.get_entrance('Dark Lake Hylia Drop (South)'),lambdastate:state.has('Flippers'))# ToDo any fake flipper set up?
set_rule(world.get_entrance('Skull Woods Final Section'),lambdastate:state.can_reach('Skull Woods Burn Skull','Entrance'))# prevent soft lock when coming from behind, not required
set_rule(world.get_entrance('Dark Desert Cave'),lambdastate:state.has_Pearl())# ToDo Bunny Revival can give access to this cave in super bunny state. Not sure how to deal with shuffled entrances, as much easier to block of cave entrances than individual shuffled chests
set_rule(world.get_entrance('Dark Desert Hint'),lambdastate:state.has_Pearl())# ToDo Bunny Revival can give access to this cave in super bunny state. Not sure how to deal with shuffled entrances, as much easier to block of cave entrances than individual shuffled chests
set_rule(world.get_entrance('Dark Desert Fairy'),lambdastate:state.has_Pearl())# ToDo Bunny Revival can give access to this cave in super bunny state. Not sure how to deal with shuffled entrances, as much easier to block of cave entrances than individual shuffled chests
set_rule(world.get_entrance('Dark Death Mountain Ascend (Top)'),lambdastate:state.has_Pearl())# Chests inside could be collected with super bunny, but may be shuffled. rather limit access for now ToDo
set_rule(world.get_entrance('Dark Death Mountain Ascend (Bottom)'),lambdastate:state.has_Pearl())
set_rule(world.get_entrance('Dark Death Mountain Ascend Exit (Bottom)'),lambdastate:False)# Cannot get to bottom exit from top. Just exists for shuffling
set_rule(world.get_location('[cave-055] Spike Cave'),lambdastate:state.has('Hammer')andstate.can_lift_rocks())# damage should be survivable always somehow. MAY need more logic ToDo
set_rule(world.get_location('[cave-056] Hookshot Cave [top right chest]'),lambdastate:state.has('Hookshot'))
set_rule(world.get_location('[cave-056] Hookshot Cave [top left chest]'),lambdastate:state.has('Hookshot'))
forlocationin['[dungeon-D4-1F] Thieves Town - Room above Boss','[dungeon-D4-B2] Thieves Town - Big Chest','[dungeon-D4-B2] Thieves Town - Chest next to Blind','Blind - Heart Container']:
(state.world.get_location('[dungeon-D5-B1] Ice Palace - Big Key Room').itemisnotNoneandstate.world.get_location('[dungeon-D5-B1] Ice Palace - Big Key Room').item.namein['Big Key (Ice Palace)'])or
(state.world.get_location('[dungeon-D5-B2] Ice Palace - Map Room').itemisnotNoneandstate.world.get_location('[dungeon-D5-B2] Ice Palace - Map Room').item.namein['Big Key (Ice Palace)']))))# if you do ipbj and waste SKs in the basement, you have to BJ over the hookshot room to fix your mess potentially. This seems fair
set_rule(world.get_entrance('Misery Mire Entrance Gap'),lambdastate:(state.has_Boots()orstate.has('Hookshot'))and(state.has_sword()orstate.has('Fire Rod')orstate.has('Ice Rod')orstate.has('Hammer')orstate.has('Cane of Somaria')orstate.has('Bow')))# need to defeat wizzrobes, bombs don't work ...
# you can squander the free small key from the pot by opening the south door to the north west switch room, locking you out of accessing a color switch ...
set_rule(world.get_entrance('Misery Mire (West)'),lambdastate:state.has('Small Key (Misery Mire)',2)if((state.world.get_location('[dungeon-D6-B1] Misery Mire - Compass Room').itemisnotNoneandstate.world.get_location('[dungeon-D6-B1] Misery Mire - Compass Room').item.namein['Big Key (Misery Mire)'])or
(state.world.get_location('[dungeon-D6-B1] Misery Mire - Big Key Room').itemisnotNoneandstate.world.get_location('[dungeon-D6-B1] Misery Mire - Big Key Room').item.namein['Big Key (Misery Mire)']))elsestate.has('Small Key (Misery Mire)',3))
set_rule(world.get_location('[dungeon-D7-1F] Turtle Rock - Compass Room'),lambdastate:state.has('Cane of Somaria'))# We could get here from the middle section without Cane as we don't cross the entrance gap!
set_rule(world.get_location('[dungeon-D7-1F] Turtle Rock - Map Room [left chest]'),lambdastate:state.has('Cane of Somaria')andstate.has('Fire Rod'))
set_rule(world.get_location('[dungeon-D7-1F] Turtle Rock - Map Room [right chest]'),lambdastate:state.has('Cane of Somaria')andstate.has('Fire Rod'))
set_rule(world.get_location('[dungeon-D7-B1] Turtle Rock - Big Chest'),lambdastate:state.has('Big Key (Turtle Rock)')and(state.has('Cane of Somaria')orstate.has('Hookshot')))
set_rule(world.get_entrance('Dark Palace Bridge Room'),lambdastate:state.has('Small Key (Palace of Darkness)',1))# If we can reach any other small key door, we already have back door access to this area
set_rule(world.get_entrance('Dark Palace Big Key Door'),lambdastate:state.has('Small Key (Palace of Darkness)',6)andstate.has('Big Key (Palace of Darkness)')andstate.has('Bow')andstate.has('Hammer'))
set_rule(world.get_entrance('Dark Palace Big Key Chest Staircase'),lambdastate:state.has('Small Key (Palace of Darkness)',6)or(state.world.get_location('[dungeon-D1-1F] Dark Palace - Big Key Room').itemisnotNoneand(state.world.get_location('[dungeon-D1-1F] Dark Palace - Big Key Room').item.namein['Small Key (Palace of Darkness)'])))
set_rule(world.get_entrance('Dark Palace Spike Statue Room Door'),lambdastate:state.has('Small Key (Palace of Darkness)',6)or(state.world.get_location('[dungeon-D1-1F] Dark Palace - Spike Statue Room').itemisnotNoneand(state.world.get_location('[dungeon-D1-1F] Dark Palace - Spike Statue Room').item.namein['Small Key (Palace of Darkness)'])))
set_rule(world.get_entrance('Dark Palace (North)'),lambdastate:state.has('Small Key (Palace of Darkness)',4))
set_rule(world.get_entrance('Dark Palace Maze Door'),lambdastate:state.has('Small Key (Palace of Darkness)',6))
set_rule(world.get_location('[dungeon-D1-1F] Dark Palace - Big Chest'),lambdastate:state.has('Big Key (Palace of Darkness)'))
set_rule(world.get_location('Ganon'),lambdastate:state.has_beam_sword()andstate.has_fire_source()and(state.has('Tempered Sword')orstate.has('Golden Sword')or(state.has('Silver Arrows')andstate.has('Bow'))orstate.has('Lamp')orstate.has('Bottle')orstate.has('Half Magic')orstate.has('Quarter Magic')))# need to light torch a sufficient amount of times
set_rule(world.get_entrance('Dark Lake Hylia Teleporter'),lambdastate:state.has_Pearl()andstate.has('Flippers')and(state.has('Hammer')orstate.can_lift_rocks()))
set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop'),lambdastate:state.has('Flippers'))
'Turtle Rock Isolated Ledge Entrance','Thieves Town','Skull Woods Final Section','Ice Palace','Misery Mire','Palace of Darkness','Swamp Palace','Turtle Rock','Dark Death Mountain Ledge (West)']
add_rule(world.get_location('[dungeon-C-B1] Escape - Final Basement Room [left chest]'),lambdastate:state.can_reach('Sewer Drop'))
add_rule(world.get_location('[dungeon-C-B1] Escape - Final Basement Room [middle chest]'),lambdastate:state.can_reach('Sewer Drop'))
add_rule(world.get_location('[dungeon-C-B1] Escape - Final Basement Room [right chest]'),lambdastate:state.can_reach('Sewer Drop'))
add_rule(world.get_location('[dungeon-C-B1] Escape - First B1 Room'),lambdastate:state.can_reach('Sewer Drop')or(state.world.get_location('[dungeon-C-B1] Escape - First B1 Room').itemisnotNoneandstate.world.get_location('[dungeon-C-B1] Escape - First B1 Room').item.namein['Small Key (Escape)']))# you could skip this chest and be unable to go back until you can drop into escape
# this is good enough to allow even key distribution but may still prevent certain valid item combinations from being placed
all_state=world.get_all_state()
# check if the back entrance into trock can be accessed. As no small keys are placed yet, the rule on the dark room staircase door
# prevents us from reach the eye bridge from within the dungeon (!)
can_reach_back=all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)'))
# if we have backdoor access we can waste a key on the trinexx door, then have no lamp to reverse traverse the maze room. We simply require an additional key just to be super safe then. The backdoor access to the chest is otherwise free
set_rule(world.get_entrance('Turtle Rock Pokey Room'),lambdastate:state.has('Small Key (Turtle Rock)',1))ifnotcan_reach_backelseset_rule(world.get_entrance('Turtle Rock Pokey Room'),lambdastate:state.has('Small Key (Turtle Rock)',2))
# if we have front access this transition is useless. If we don't, it's a dead end so cannot hold any small keys
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)'),lambdastate:state.has('Small Key (Turtle Rock)',4))
# this is just the pokey room with one more key
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'),lambdastate:state.has('Small Key (Turtle Rock)',2))ifnotcan_reach_backelseset_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'),lambdastate:state.has('Small Key (Turtle Rock)',3))
# the most complicated one
# if we have back entrance access, we could waste all keys before touching this
# if we don't, we have access to all chests by the time we can waste a key on trinexx door
# in that case, if it contains the big key, we can also not waste a key on the roller switch door
set_rule(world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room'),lambdastate:state.has('Small Key (Turtle Rock)',4)or(state.world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room').itemisnotNoneand(state.world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room').item.namein['Small Key (Turtle Rock)'])))ifcan_reach_backelse \
set_rule(world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room'),lambdastate:state.has('Small Key (Turtle Rock)',2)if(state.world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room').itemisnotNoneand(state.world.get_location('[dungeon-D7-B1] Turtle Rock - Big Key Room').item.namein['Big Key (Turtle Rock)']))elsestate.has('Small Key (Turtle Rock)',3))
# set big key restrictions
non_big_key_locations=['[dungeon-D7-B1] Turtle Rock - Big Chest','Trinexx - Heart Container']
ifnotcan_reach_back:
non_big_key_locations+=['[dungeon-D7-B1] Turtle Rock - Roller Switch Room','[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [bottom left chest]',
'[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [bottom right chest]','[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [top left chest]',
'[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [top right chest]']
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks())orstate.has_Mirror())
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.has_Mirror()and(state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks())))
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:(state.can_lift_heavy_rocks()andstate.has('Hammer'))or(state.has_Mirror()and(state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks()))))
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.has('Hammer')or(state.has_Mirror()and(state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks()))))
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.has_Mirror()andstate.has('Ocarina')and(state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks())))
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.has('Ocarina')and(state.can_reach('Top of Pyramid','Entrance')or(state.has('Hammer')andstate.can_lift_rocks())))
elifbombshop_entrance.name=='Dark World Potion Shop':
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.has('Hammer')orstate.can_lift_rocks()or(state.has_Mirror()andstate.can_reach('Top of Pyramid','Entrance')))
elifbombshop_entrance.name=='Kings Grave':
add_rule(world.get_entrance('Pyramid Fairy'),lambdastate:state.can_reach('Top of Pyramid','Entrance')or(state.can_lift_rocks()andstate.has('Hammer'))or(state.can_lift_heavy_rocks()andstate.has_Mirror()))