Archipelago/test/general/test_reachability.py

82 lines
4.2 KiB
Python
Raw Normal View History

import unittest
from BaseClasses import CollectionState
from worlds.AutoWorld import AutoWorldRegister
from . import setup_solo_multiworld, gen_steps
2022-04-01 01:32:17 +00:00
class TestBase(unittest.TestCase):
gen_steps = gen_steps
default_settings_unreachable_regions = {
"A Link to the Past": {
"Chris Houlihan Room", # glitch room by definition
"Desert Northern Cliffs", # on top of mountain, only reachable via OWG
"Dark Death Mountain Bunny Descent Area" # OWG Mountain descent
},
Blasphemous: Total overhaul (#3355) * Blasphemous: WIP overhaul * Entrance rule mistake * stuff * Getting closer * Real?? Maybe?? * Don't fail me now 🙏 * Add starting location tests * More tests (it still doesn't work actually 😔) * REAL * Add unreachable regions to test_reachability.py * PR ready - Remove unused functions from init - Use group exclusive functions in rules - Style changes * Bump required client version * Clean up unused imports * Change slot data * Review fixes - Prevent strength calculations from including excess items - Add new lines to ends of files - Fix missed deprecated option and random usage in init * Update option docstrings, add groups * Add preprocessor files * Update option docstrings again actually * Update player strength calculation * Rename group methods * Fix missing logic for RESCUED_CHERUB_06 * Register indirect conditions * Register indirect conditions (part 2) * Update extracted logic, change slot data key * Add region to excluded list * A capital letter * Use camelCase keys in preprocessor * Write some of new setup guide * Remove indents before list points * Change locationinfo to list of dictonaries * Finish docs, update extractor config and data * Mark region_data.py as generated * Suggested changes * More suggested changes * Suggested changes again - Use OptionError - Create list of disabled locations before looping - Check if options are equal to str instead of int - Clean up start location override - Reword some of setup guide - Organize location list - Remove unnecessary escaped quotes from option docstrings - Add world type to test base * C# moment * Requested changes * Update .gitattributes --------- Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-08-20 23:18:28 +00:00
# These Blasphemous regions are not reachable with default options
"Blasphemous": {
"D01Z04S13[SE]", # difficulty must be hard
"D01Z05S25[E]", # difficulty must be hard
"D02Z02S05[W]", # difficulty must be hard and purified_hand must be true
"D04Z01S06[E]", # purified_hand must be true
"D04Z02S02[NE]", # difficulty must be hard and purified_hand must be true
"D05Z01S11[SW]", # difficulty must be hard
"D06Z01S08[N]", # difficulty must be hard and purified_hand must be true
"D20Z02S11[NW]", # difficulty must be hard
"D20Z02S11[E]", # difficulty must be hard
},
"Ocarina of Time": {
"Prelude of Light Warp", # Prelude is not progression by default
"Serenade of Water Warp", # Serenade is not progression by default
"Lost Woods Mushroom Timeout", # trade quest starts after this item
"ZD Eyeball Frog Timeout", # trade quest starts after this item
"ZR Top of Waterfall", # dummy region used for entrance shuffle
},
2023-05-31 02:16:39 +00:00
# The following SM regions are only used when the corresponding StartLocation option is selected (so not with
# default settings). Also, those don't have any entrances as they serve as starting Region (that's why they
# have to be excluded for testAllStateCanReachEverything).
"Super Metroid": {
"Ceres",
"Gauntlet Top",
"Mama Turtle"
}
}
def test_default_all_state_can_reach_everything(self):
"""Ensure all state can reach everything and complete the game with the defined options"""
for game_name, world_type in AutoWorldRegister.world_types.items():
unreachable_regions = self.default_settings_unreachable_regions.get(game_name, set())
with self.subTest("Game", game=game_name):
multiworld = setup_solo_multiworld(world_type)
state = multiworld.get_all_state(False)
for location in multiworld.get_locations():
with self.subTest("Location should be reached", location=location.name):
self.assertTrue(location.can_reach(state), f"{location.name} unreachable")
for region in multiworld.get_regions():
if region.name in unreachable_regions:
with self.subTest("Region should be unreachable", region=region.name):
self.assertFalse(region.can_reach(state))
else:
with self.subTest("Region should be reached", region=region.name):
self.assertTrue(region.can_reach(state))
with self.subTest("Completion Condition"):
self.assertTrue(multiworld.can_beat_game(state))
def test_default_empty_state_can_reach_something(self):
"""Ensure empty state can reach at least one location with the defined options"""
for game_name, world_type in AutoWorldRegister.world_types.items():
2023-05-31 02:16:39 +00:00
with self.subTest("Game", game=game_name):
multiworld = setup_solo_multiworld(world_type)
state = CollectionState(multiworld)
all_locations = multiworld.get_locations()
2023-05-31 02:16:39 +00:00
if all_locations:
locations = set()
2023-05-31 02:16:39 +00:00
for location in all_locations:
if location.can_reach(state):
locations.add(location)
self.assertGreater(len(locations), 0,
msg="Need to be able to reach at least one location to get started.")