# Caution: If king's grave is releaxed at all to account for reaching it via a two way cave's exit in insanity mode, then the bomb shop logic will need to be updated (that would involve create a small ledge-like Region for it)
set_rule(world.get_entrance('Waterfall of Wishing',player),lambdastate:state.has('Flippers',player))# 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_location('Frog',player),lambdastate:state.can_lift_heavy_rocks(player))# will get automatic moon pearl requirement
set_rule(world.get_location('Missing Smith',player),lambdastate:state.has('Get Frog',player))# Can S&Q with smith
set_rule(world.get_entrance('Desert Ledge Return Rocks',player),lambdastate:state.can_lift_rocks(player))# should we decide to place something that is not a dungeon end up there at some point
set_rule(world.get_entrance('Northeast Dark World Broken Bridge Pass',player),lambdastate:state.has_Pearl(player)and(state.can_lift_rocks(player)orstate.has('Hammer',player)orstate.has('Flippers',player)))
set_rule(world.get_entrance('East Dark World Broken Bridge Pass',player),lambdastate:state.has_Pearl(player)and(state.can_lift_rocks(player)orstate.has('Hammer',player)))
set_rule(world.get_entrance('South Dark World Bridge',player),lambdastate:state.has('Hammer',player)andstate.has_Pearl(player))
set_rule(world.get_entrance('Hyrule Castle Main Gate',player),lambdastate:state.has_Mirror(player))
set_rule(world.get_entrance('Dark Lake Hylia Drop (East)',player),lambdastate:(state.has_Pearl(player)andstate.has('Flippers',player)orstate.has_Mirror(player)))# Overworld Bunny Revival
set_rule(world.get_location('Bombos Tablet',player),lambdastate:state.has('Book of Mudora',player)andstate.has_beam_sword(player)andstate.has_Mirror(player))
set_rule(world.get_entrance('Dark Lake Hylia Drop (South)',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player))# ToDo any fake flipper set up?
set_rule(world.get_entrance('Dark Lake Hylia Ledge Fairy',player),lambdastate:state.has_Pearl(player))# bomb required
set_rule(world.get_entrance('Dark Lake Hylia Ledge Spike Cave',player),lambdastate:state.can_lift_rocks(player)andstate.has_Pearl(player))
set_rule(world.get_entrance('Dark Lake Hylia Teleporter',player),lambdastate:state.has_Pearl(player)and(state.has('Hammer',player)orstate.can_lift_rocks(player)))# Fake Flippers
set_rule(world.get_entrance('Village of Outcasts Heavy Rock',player),lambdastate:state.has_Pearl(player)andstate.can_lift_heavy_rocks(player))
set_rule(world.get_entrance('East Dark World Bridge',player),lambdastate:state.has_Pearl(player)andstate.has('Hammer',player))
set_rule(world.get_entrance('Lake Hylia Island Mirror Spot',player),lambdastate:state.has_Pearl(player)andstate.has_Mirror(player)andstate.has('Flippers',player))
set_rule(world.get_entrance('Lake Hylia Central Island Mirror Spot',player),lambdastate:state.has_Mirror(player))
set_rule(world.get_entrance('East Dark World River Pier',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player))# ToDo any fake flipper set up?
set_rule(world.get_entrance('Skull Woods Final Section',player),lambdastate:state.has('Fire Rod',player)andstate.has_Pearl(player))# bunny cannot use fire rod
set_rule(world.get_entrance('Misery Mire',player),lambdastate:state.has_Pearl(player)andstate.has_sword(player)andstate.has_misery_mire_medallion(player))# sword required to cast magic (!)
set_rule(world.get_entrance('Fairy Ascension Mirror Spot',player),lambdastate:state.has_Mirror(player)andstate.has_Pearl(player))# need to lift flowers
set_rule(world.get_entrance('Floating Island Mirror Spot',player),lambdastate:state.has_Mirror(player))
set_rule(world.get_entrance('Turtle Rock',player),lambdastate:state.has_Pearl(player)andstate.has_sword(player)andstate.has_turtle_rock_medallion(player)andstate.can_reach('Turtle Rock (Top)','Region',player))# sword required to cast magic (!)
set_rule(world.get_entrance('Tower of Hera Small Key Door',player),lambdastate:state.has_key('Small Key (Tower of Hera)',player)oritem_name(state,'Tower of Hera - Big Key Chest',player)==('Small Key (Tower of Hera)',player))
set_rule(world.get_entrance('Tower of Hera Big Key Door',player),lambdastate:state.has('Big Key (Tower of Hera)',player))
set_rule(world.get_location('Tower of Hera - Big Chest',player),lambdastate:state.has('Big Key (Tower of Hera)',player))
set_rule(world.get_location('Tower of Hera - Big Key Chest',player),lambdastate:state.has_fire_source(player))
set_always_allow(world.get_location('Tower of Hera - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Tower of Hera)'anditem.player==player)
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize',player))
set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Prize',player))
set_rule(world.get_location('Thieves\' Town - Big Chest',player),lambdastate:(state.has_key('Small Key (Thieves Town)',player)oritem_name(state,'Thieves\' Town - Big Chest',player)==('Small Key (Thieves Town)',player))andstate.has('Hammer',player))
set_always_allow(world.get_location('Thieves\' Town - Big Chest',player),lambdastate,item:item.name=='Small Key (Thieves Town)'anditem.player==playerandstate.has('Hammer',player))
set_rule(world.get_location('Thieves\' Town - Attic',player),lambdastate:state.has_key('Small Key (Thieves Town)',player))
set_rule(world.get_entrance('Skull Woods First Section South Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player))
set_rule(world.get_entrance('Skull Woods First Section (Right) North Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player))
set_rule(world.get_entrance('Skull Woods First Section West Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player,2))# ideally would only be one key, but we may have spent thst key already on escaping the right section
set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit',player),lambdastate:state.has_key('Small Key (Skull Woods)',player,2))
set_rule(world.get_location('Skull Woods - Big Chest',player),lambdastate:state.has('Big Key (Skull Woods)',player)oritem_name(state,'Skull Woods - Big Chest',player)==('Big Key (Skull Woods)',player))
set_always_allow(world.get_location('Skull Woods - Big Chest',player),lambdastate,item:item.name=='Big Key (Skull Woods)'anditem.player==player)
set_rule(world.get_entrance('Misery Mire Entrance Gap',player),lambdastate:(state.has_Boots(player)orstate.has('Hookshot',player))and(state.has_sword(player)orstate.has('Fire Rod',player)orstate.has('Ice Rod',player)orstate.has('Hammer',player)orstate.has('Cane of Somaria',player)orstate.can_shoot_arrows(player)))# need to defeat wizzrobes, bombs don't work ...
set_rule(world.get_location('Misery Mire - Big Chest',player),lambdastate:state.has('Big Key (Misery Mire)',player))
set_rule(world.get_location('Misery Mire - Spike Chest',player),lambdastate:(state.world.can_take_damageandstate.has_hearts(player,4))orstate.has('Cane of Byrna',player)orstate.has('Cape',player))
set_rule(world.get_entrance('Misery Mire Big Key Door',player),lambdastate:state.has('Big Key (Misery Mire)',player))
# 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('Turtle Rock Entrance Gap',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_location('Turtle Rock - Compass Chest',player),lambdastate:state.has('Cane of Somaria',player))# We could get here from the middle section without Cane as we don't cross the entrance gap!
set_rule(world.get_location('Turtle Rock - Roller Room - Left',player),lambdastate:state.has('Cane of Somaria',player)andstate.has('Fire Rod',player))
set_rule(world.get_location('Turtle Rock - Roller Room - Right',player),lambdastate:state.has('Cane of Somaria',player)andstate.has('Fire Rod',player))
set_rule(world.get_location('Turtle Rock - Big Chest',player),lambdastate:state.has('Big Key (Turtle Rock)',player)and(state.has('Cane of Somaria',player)orstate.has('Hookshot',player)))
set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)',player),lambdastate:state.has('Cane of Somaria',player)orstate.has('Hookshot',player))
set_rule(world.get_entrance('Turtle Rock Big Key Door',player),lambdastate:state.has('Big Key (Turtle Rock)',player))
set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_entrance('Turtle Rock (Trinexx)',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,4)andstate.has('Big Key (Turtle Rock)',player)andstate.has('Cane of Somaria',player))
set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Prize',player))
set_rule(world.get_entrance('Palace of Darkness Bonk Wall',player),lambdastate:state.can_shoot_arrows(player))
set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop',player),lambdastate:state.has('Hammer',player))
set_rule(world.get_entrance('Palace of Darkness Bridge Room',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,1))# If we can reach any other small key door, we already have back door access to this area
set_rule(world.get_entrance('Palace of Darkness Big Key Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)andstate.has('Big Key (Palace of Darkness)',player)andstate.can_shoot_arrows(player)andstate.has('Hammer',player))
set_rule(world.get_entrance('Palace of Darkness (North)',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,4))
set_rule(world.get_location('Palace of Darkness - Big Chest',player),lambdastate:state.has('Big Key (Palace of Darkness)',player))
set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)or(item_name(state,'Palace of Darkness - Big Key Chest',player)in[('Small Key (Palace of Darkness)',player)]andstate.has_key('Small Key (Palace of Darkness)',player,3)))
set_always_allow(world.get_location('Palace of Darkness - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Palace of Darkness)'anditem.player==playerandstate.has_key('Small Key (Palace of Darkness)',player,5))
set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)or(item_name(state,'Palace of Darkness - Harmless Hellway',player)in[('Small Key (Palace of Darkness)',player)]andstate.has_key('Small Key (Palace of Darkness)',player,4)))
set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway',player),lambdastate,item:item.name=='Small Key (Palace of Darkness)'anditem.player==playerandstate.has_key('Small Key (Palace of Darkness)',player,5))
set_rule(world.get_entrance('Palace of Darkness Maze Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize',player))
and(state.has('Tempered Sword',player)orstate.has('Golden Sword',player)or(state.has('Silver Arrows',player)andstate.can_shoot_arrows(player))orstate.has('Lamp',player)orstate.can_extend_magic(player,12)))# need to light torch a sufficient amount of times
set_rule(world.get_entrance('Ganon Drop',player),lambdastate:state.has_beam_sword(player))# need to damage ganon to get tiles to drop
set_rule(world.get_entrance('Ganons Tower',player),lambdastate:False)# This is a safety for the TR function below to not require GT entrance in its key logic.
# Caution: If king's grave is releaxed at all to account for reaching it via a two way cave's exit in insanity mode, then the bomb shop logic will need to be updated (that would involve create a small ledge-like Region for it)
set_rule(world.get_entrance('Bat Cave Drop Ledge',player),lambdastate:state.has('Hammer',player)andstate.has_Pearl(player))
set_rule(world.get_entrance('Lumberjack Tree Tree',player),lambdastate:state.has_Boots(player)andstate.has_Pearl(player)andstate.has('Beat Agahnim 1',player))
set_rule(world.get_entrance('Bonk Rock Cave',player),lambdastate:state.has_Boots(player)andstate.has_Pearl(player))
set_rule(world.get_entrance('Desert Palace Stairs',player),lambdastate:state.has('Book of Mudora',player))# bunny can use book
set_rule(world.get_entrance('East Dark World Teleporter',player),lambdastate:state.has('Hammer',player)andstate.can_lift_rocks(player)andstate.has_Pearl(player))# bunny cannot use hammer
set_rule(world.get_entrance('South Dark World Teleporter',player),lambdastate:state.has('Hammer',player)andstate.can_lift_rocks(player)andstate.has_Pearl(player))# bunny cannot use hammer
set_rule(world.get_entrance('West Dark World Teleporter',player),lambdastate:((state.has('Hammer',player)andstate.can_lift_rocks(player))orstate.can_lift_heavy_rocks(player))andstate.has_Pearl(player))
set_rule(world.get_entrance('Waterfall of Wishing',player),lambdastate:state.has('Flippers',player)andstate.has_Pearl(player))# 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_location('Missing Smith',player),lambdastate:state.has('Get Frog',player)andstate.can_reach('Blacksmiths Hut','Region',player))# Can't S&Q with smith
set_rule(world.get_location('Potion Shop',player),lambdastate:state.has('Mushroom',player)and(state.can_reach('Potion Shop Area','Region',player)))# new inverted region, need pearl for bushes or access to potion shop door/waterfall fairy
set_rule(world.get_entrance('Desert Ledge Return Rocks',player),lambdastate:state.can_lift_rocks(player)andstate.has_Pearl(player))# should we decide to place something that is not a dungeon end up there at some point
set_rule(world.get_entrance('Dark Death Mountain Teleporter (East)',player),lambdastate:state.can_lift_heavy_rocks(player)andstate.has('Hammer',player)andstate.has_Pearl(player))# bunny cannot use hammer
set_rule(world.get_location('Ether Tablet',player),lambdastate:state.has('Book of Mudora',player)andstate.has_beam_sword(player))
set_rule(world.get_entrance('East Death Mountain (Top)',player),lambdastate:state.has('Hammer',player)andstate.has_Pearl(player))# bunny can not use hammer
set_rule(world.get_entrance('Northeast Dark World Broken Bridge Pass',player),lambdastate:((state.can_lift_rocks(player)orstate.has('Hammer',player))orstate.has('Flippers',player)))
set_rule(world.get_entrance('East Dark World Broken Bridge Pass',player),lambdastate:(state.can_lift_rocks(player)orstate.has('Hammer',player)))
set_rule(world.get_entrance('South Dark World Bridge',player),lambdastate:state.has('Hammer',player))
set_rule(world.get_entrance('Floating Island Mirror Spot',player),lambdastate:state.has_Mirror(player))
set_rule(world.get_entrance('Turtle Rock',player),lambdastate:state.has_sword(player)andstate.has_turtle_rock_medallion(player)andstate.can_reach('Turtle Rock (Top)','Region',player))# sword required to cast magic (!)
set_rule(world.get_entrance('Tower of Hera Small Key Door',player),lambdastate:state.has_key('Small Key (Tower of Hera)',player)oritem_name(state,'Tower of Hera - Big Key Chest',player)==('Small Key (Tower of Hera)',player))
set_rule(world.get_entrance('Tower of Hera Big Key Door',player),lambdastate:state.has('Big Key (Tower of Hera)',player))
set_rule(world.get_location('Tower of Hera - Big Chest',player),lambdastate:state.has('Big Key (Tower of Hera)',player))
set_rule(world.get_location('Tower of Hera - Big Key Chest',player),lambdastate:state.has_fire_source(player))
set_always_allow(world.get_location('Tower of Hera - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Tower of Hera)'anditem.player==player)
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize',player))
forlocationin['Tower of Hera - Boss','Tower of Hera - Big Chest','Tower of Hera - Compass Chest']:
forbid_item(world.get_location(location,player),'Big Key (Tower of Hera)',player)
# for location in ['Tower of Hera - Big Key Chest']:
# forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player)
set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Prize',player))
set_rule(world.get_location('Thieves\' Town - Big Chest',player),lambdastate:(state.has_key('Small Key (Thieves Town)',player)oritem_name(state,'Thieves\' Town - Big Chest',player)==('Small Key (Thieves Town)',player))andstate.has('Hammer',player))
set_always_allow(world.get_location('Thieves\' Town - Big Chest',player),lambdastate,item:item.name=='Small Key (Thieves Town)'anditem.player==playerandstate.has('Hammer',player))
set_rule(world.get_location('Thieves\' Town - Attic',player),lambdastate:state.has_key('Small Key (Thieves Town)',player))
forlocationin['Thieves\' Town - Attic','Thieves\' Town - Big Chest','Thieves\' Town - Blind\'s Cell','Thieves\' Town - Boss']:
set_rule(world.get_entrance('Skull Woods First Section South Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player))
set_rule(world.get_entrance('Skull Woods First Section (Right) North Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player))
set_rule(world.get_entrance('Skull Woods First Section West Door',player),lambdastate:state.has_key('Small Key (Skull Woods)',player,2))# ideally would only be one key, but we may have spent thst key already on escaping the right section
set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit',player),lambdastate:state.has_key('Small Key (Skull Woods)',player,2))
set_rule(world.get_location('Skull Woods - Big Chest',player),lambdastate:state.has('Big Key (Skull Woods)',player)oritem_name(state,'Skull Woods - Big Chest',player)==('Big Key (Skull Woods)',player))
set_always_allow(world.get_location('Skull Woods - Big Chest',player),lambdastate,item:item.name=='Big Key (Skull Woods)'anditem.player==player)
set_rule(world.get_entrance('Misery Mire Entrance Gap',player),lambdastate:(state.has_Boots(player)orstate.has('Hookshot',player))and(state.has_sword(player)orstate.has('Fire Rod',player)orstate.has('Ice Rod',player)orstate.has('Hammer',player)orstate.has('Cane of Somaria',player)orstate.can_shoot_arrows(player)))# need to defeat wizzrobes, bombs don't work ...
set_rule(world.get_location('Misery Mire - Big Chest',player),lambdastate:state.has('Big Key (Misery Mire)',player))
set_rule(world.get_location('Misery Mire - Spike Chest',player),lambdastate:(state.world.can_take_damageandstate.has_hearts(player,4))orstate.has('Cane of Byrna',player)orstate.has('Cape',player))
set_rule(world.get_entrance('Misery Mire Big Key Door',player),lambdastate:state.has('Big Key (Misery Mire)',player))
# 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 ...
# big key gives backdoor access to that from the teleporter in the north west
set_rule(world.get_entrance('Turtle Rock Entrance Gap',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_location('Turtle Rock - Compass Chest',player),lambdastate:state.has('Cane of Somaria',player))# We could get here from the middle section without Cane as we don't cross the entrance gap!
set_rule(world.get_location('Turtle Rock - Roller Room - Left',player),lambdastate:state.has('Cane of Somaria',player)andstate.has('Fire Rod',player))
set_rule(world.get_location('Turtle Rock - Roller Room - Right',player),lambdastate:state.has('Cane of Somaria',player)andstate.has('Fire Rod',player))
set_rule(world.get_location('Turtle Rock - Big Chest',player),lambdastate:state.has('Big Key (Turtle Rock)',player)and(state.has('Cane of Somaria',player)orstate.has('Hookshot',player)))
set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)',player),lambdastate:state.has('Cane of Somaria',player)orstate.has('Hookshot',player))
set_rule(world.get_entrance('Turtle Rock Big Key Door',player),lambdastate:state.has('Big Key (Turtle Rock)',player))
set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)',player),lambdastate:state.has('Cane of Somaria',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right',player),lambdastate:state.has('Cane of Byrna',player)orstate.has('Cape',player)orstate.has('Mirror Shield',player))
set_rule(world.get_entrance('Turtle Rock (Trinexx)',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,4)andstate.has('Big Key (Turtle Rock)',player)andstate.has('Cane of Somaria',player))
set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Prize',player))
set_rule(world.get_entrance('Palace of Darkness Bonk Wall',player),lambdastate:state.can_shoot_arrows(player))
set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop',player),lambdastate:state.has('Hammer',player))
set_rule(world.get_entrance('Palace of Darkness Bridge Room',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,1))# If we can reach any other small key door, we already have back door access to this area
set_rule(world.get_entrance('Palace of Darkness Big Key Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)andstate.has('Big Key (Palace of Darkness)',player)andstate.can_shoot_arrows(player)andstate.has('Hammer',player))
set_rule(world.get_entrance('Palace of Darkness (North)',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,4))
set_rule(world.get_location('Palace of Darkness - Big Chest',player),lambdastate:state.has('Big Key (Palace of Darkness)',player))
set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)or(item_name(state,'Palace of Darkness - Big Key Chest',player)in[('Small Key (Palace of Darkness)',player)]andstate.has_key('Small Key (Palace of Darkness)',player,3)))
set_always_allow(world.get_location('Palace of Darkness - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Palace of Darkness)'anditem.player==playerandstate.has_key('Small Key (Palace of Darkness)',player,5))
set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6)or(item_name(state,'Palace of Darkness - Harmless Hellway',player)in[('Small Key (Palace of Darkness)',player)]andstate.has_key('Small Key (Palace of Darkness)',player,4)))
set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway',player),lambdastate,item:item.name=='Small Key (Palace of Darkness)'anditem.player==playerandstate.has_key('Small Key (Palace of Darkness)',player,5))
set_rule(world.get_entrance('Palace of Darkness Maze Door',player),lambdastate:state.has_key('Small Key (Palace of Darkness)',player,6))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss',player))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize',player))
# these key rules are conservative, you might be able to get away with more lenient rules
and(state.has('Tempered Sword',player)orstate.has('Golden Sword',player)or(state.has('Silver Arrows',player)andstate.can_shoot_arrows(player))orstate.has('Lamp',player)orstate.can_extend_magic(player,12)))# need to light torch a sufficient amount of times
set_rule(world.get_entrance('Ganon Drop',player),lambdastate:state.has_beam_sword(player))# need to damage ganon to get tiles to drop
set_rule(world.get_entrance('Inverted Ganons Tower',player),lambdastate:False)# This is a safety for the TR function below to not require GT entrance in its key logic.
set_rule(world.get_entrance('Dark Lake Hylia Drop (East)',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player))
set_rule(world.get_entrance('Dark Lake Hylia Teleporter',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player)and(state.has('Hammer',player)orstate.can_lift_rocks(player)))
set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player))
set_rule(world.get_entrance('Lake Hylia Central Island Pier',player),lambdastate:state.has_Pearl(player)andstate.has('Flippers',player))# can be fake flippered to
set_rule(world.get_entrance('Dark Lake Hylia Drop (East)',player),lambdastate:state.has('Flippers',player))
set_rule(world.get_entrance('Dark Lake Hylia Teleporter',player),lambdastate:state.has('Flippers',player)and(state.has('Hammer',player)orstate.can_lift_rocks(player)))
set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop',player),lambdastate:state.has('Flippers',player))
'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)']
set_rule(world.get_entrance('Agahnims Tower',player),lambdastate:state.has('Cape',player)orstate.has('Hammer',player)orstate.has('Beat Agahnim 1',player))# barrier gets removed after killing agahnim, relevant for entrance shuffle
set_rule(world.get_entrance('Agahnim 1',player),lambdastate:(state.has('Hammer',player)orstate.has('Fire Rod',player)orstate.can_shoot_arrows(player)orstate.has('Cane of Somaria',player))andstate.has_key('Small Key (Agahnims Tower)',player,2))
set_rule(world.get_location('Ether Tablet',player),lambdastate:state.has('Book of Mudora',player)andstate.has('Hammer',player))
set_rule(world.get_location('Bombos Tablet',player),lambdastate:state.has('Book of Mudora',player)andstate.has('Hammer',player)andstate.has_Mirror(player))
set_rule(world.get_entrance('Misery Mire',player),lambdastate:state.has_Pearl(player)andstate.has_misery_mire_medallion(player))# sword not required to use medallion for opening in swordless (!)
set_rule(world.get_entrance('Turtle Rock',player),lambdastate:state.has_Pearl(player)andstate.has_turtle_rock_medallion(player)andstate.can_reach('Turtle Rock (Top)','Region',player))# sword not required to use medallion for opening in swordless (!)
set_rule(world.get_entrance('Skull Woods Torch Room',player),lambdastate:state.has_key('Small Key (Skull Woods)',player,3)andstate.has('Fire Rod',player))# no curtain
set_rule(world.get_entrance('Ice Palace Entrance Room',player),lambdastate:state.has('Fire Rod',player)orstate.has('Bombos',player))#in swordless mode bombos pads are present in the relevant parts of ice palace
# First set all relevant locked doors to impassible.
forentrancein['Turtle Rock Dark Room Staircase','Turtle Rock (Chain Chomp Room) (North)','Turtle Rock (Chain Chomp Room) (South)','Turtle Rock Pokey Room']:
can_reach_back=all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)',player))ifworld.can_access_trock_eyebridgeisNoneelseworld.can_access_trock_eyebridge
can_reach_front=all_state.can_reach(world.get_region('Turtle Rock (Entrance)',player))ifworld.can_access_trock_frontisNoneelseworld.can_access_trock_front
can_reach_big_chest=all_state.can_reach(world.get_region('Turtle Rock (Big Chest)',player))ifworld.can_access_trock_big_chestisNoneelseworld.can_access_trock_big_chest
can_reach_middle=all_state.can_reach(world.get_region('Turtle Rock (Second Section)',player))ifworld.can_access_trock_middleisNoneelseworld.can_access_trock_middle
# Now we need to set rules based on which entrances we have access to. The most important point is whether we have back access. If we have back access, we
# might open all the locked doors in any order so we need maximally restrictive rules.
set_rule(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate:(state.has_key('Small Key (Turtle Rock)',player,4)oritem_name(state,'Turtle Rock - Big Key Chest',player)==('Small Key (Turtle Rock)',player)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Turtle Rock)'anditem.player==player)
set_rule(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,tr_big_key_chest_keys_needed(state)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Turtle Rock)'anditem.player==player)
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,2))
set_rule(world.get_entrance('Turtle Rock Pokey Room',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,1))
set_rule(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,tr_big_key_chest_keys_needed(state)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Turtle Rock)'anditem.player==playerandstate.has_key('Small Key (Turtle Rock)',player,2))
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,2)ifitem_in_locations(state,'Big Key (Turtle Rock)',player,[('Turtle Rock - Compass Chest',player),('Turtle Rock - Roller Room - Left',player),('Turtle Rock - Roller Room - Right',player)])elsestate.has_key('Small Key (Turtle Rock)',player,4))
set_rule(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate:(state.has_key('Small Key (Turtle Rock)',player,4)oritem_name(state,'Turtle Rock - Big Key Chest',player)==('Small Key (Turtle Rock)',player)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Turtle Rock)'anditem.player==player)
set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)',player),lambdastate:state.has_key('Small Key (Turtle Rock)',player,2)ifitem_in_locations(state,'Big Key (Turtle Rock)',player,[('Turtle Rock - Compass Chest',player),('Turtle Rock - Roller Room - Left',player),('Turtle Rock - Roller Room - Right',player)])elsestate.has_key('Small Key (Turtle Rock)',player,4))
set_rule(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate:(state.has_key('Small Key (Turtle Rock)',player,4)oritem_name(state,'Turtle Rock - Big Key Chest',player)==('Small Key (Turtle Rock)',player)))
set_always_allow(world.get_location('Turtle Rock - Big Key Chest',player),lambdastate,item:item.name=='Small Key (Turtle Rock)'anditem.player==player)
#2. Mirror and Flute and basic routes (can make difference if accessed via insanity or w/ mirror from connector, and then via hyrule castle gate, because no gloves are needed in that case)
#3. Go to south DW and then cross peg bridge: Need Mitts and hammer and moon pearl
# -> (Mitts and CPB) or (((G or Flute) and M) and BR))
add_rule(world.get_entrance('Pyramid Fairy',player),lambdastate:cross_peg_bridge(state)or(state.has_Mirror(player)andstate.can_reach('Top of Pyramid','Entrance',player)))
add_rule(world.get_entrance('Pyramid Fairy',player),lambdastate:(state.has('Ocarina',player)or(state.can_reach('West Dark World','Region',player)andstate.has_Pearl(player)andstate.has_Mirror(player)))andbasic_routes(state))
add_rule(world.get_entrance('Pyramid Fairy',player),lambdastate:(state.has('Ocarina',player)or(state.can_reach('South Dark World','Region',player)andstate.has_Mirror(player)))andbasic_routes(state))
add_rule(world.get_entrance('Pyramid Fairy',player),lambdastate:(state.can_lift_heavy_rocks(player)andstate.has_Mirror(player))or((state.can_lift_heavy_rocks(player)orstate.has('Ocarina',player)or(state.can_reach('West Dark World','Region',player)andstate.has_Pearl(player)andstate.has_Mirror(player)))andbasic_routes(state)))
set_rule(world.get_entrance('Pyramid Fairy',player),lambdastate:state.can_reach('East Dark World','Region',player)andstate.can_reach('Inverted Big Bomb Shop','Region',player)andstate.has('Crystal 5',player)andstate.has('Crystal 6',player))
#crossing peg bridge starting from the southern dark world
# Note spiral cave may be technically passible, but it would be too absurd to require since OHKO mode is a thing.
bunny_impassable_caves=['Bumper Cave','Two Brothers House','Hookshot Cave','Skull Woods First Section (Right)','Skull Woods First Section (Left)','Skull Woods First Section (Top)','Turtle Rock (Entrance)','Turtle Rock (Second Section)','Turtle Rock (Big Chest)','Skull Woods Second Section (Drop)',
# regions for the exits of multi-entrace caves/drops that bunny cannot pass
# Note spiral cave may be technically passible, but it would be too absurd to require since OHKO mode is a thing.
bunny_impassable_caves=['Bumper Cave','Two Brothers House','Hookshot Cave','Skull Woods First Section (Right)','Skull Woods First Section (Left)','Skull Woods First Section (Top)','Turtle Rock (Entrance)','Turtle Rock (Second Section)','Turtle Rock (Big Chest)','Skull Woods Second Section (Drop)',
'Turtle Rock (Eye Bridge)','Sewers','Pyramid','Spiral Cave (Top)','Desert Palace Main (Inner)','Fairy Ascension Cave (Drop)','The Sky']