refactor find_available_areas a bit

no semantic changes, just condensing some repeated code for clarity.
wip-faster-paths
magical 2024-02-07 22:40:15 -08:00
parent ab089feb6e
commit b95fef681f
1 changed files with 28 additions and 108 deletions

View File

@ -1624,8 +1624,8 @@ def update_requirements(graph):
def find_available_areas(graph): def find_available_areas(graph):
check = int(StartLocation[1:2]) AreaOpen[int(StartLocation[1:2])] = StartLocation
AreaOpen[check] = StartLocation
if AreaOpen[0] == None: if AreaOpen[0] == None:
check = 'S0-32' check = 'S0-32'
path = graph.get_path(StartLocation, check) path = graph.get_path(StartLocation, check)
@ -1633,94 +1633,33 @@ def find_available_areas(graph):
path = graph.get_path(check, StartLocation) path = graph.get_path(check, StartLocation)
if path != None: if path != None:
AreaOpen[0] = check AreaOpen[0] = check
if AreaOpen[1] == None:
check = 'S1-00' def check_sector(area, check, tunnel1, tunnel2):
if AreaOpen[area] == None:
path = graph.get_path(StartLocation, check) path = graph.get_path(StartLocation, check)
if path != None: if path != None:
path = graph.get_path(check, StartLocation) path = graph.get_path(check, StartLocation)
if path != None: if path != None:
AreaOpen[1] = check AreaOpen[area] = check
if ScrewAttack: if ScrewAttack:
if AreaOpen[1] == None: if AreaOpen[area] == None:
check = 'S1-6B' path = graph.get_path(StartLocation, tunnel1)
path = graph.get_path(StartLocation, check)
if path != None: if path != None:
path = graph.get_path(check, StartLocation) path = graph.get_path(tunnel1, StartLocation)
if path != None: if path != None:
AreaOpen[1] = check AreaOpen[area] = tunnel1
if AreaOpen[1] == None: if AreaOpen[area] == None:
check = 'S1-68' path = graph.get_path(StartLocation, tunnel2)
path = graph.get_path(StartLocation, check)
if path != None: if path != None:
path = graph.get_path(check, StartLocation) path = graph.get_path(tunnel2, StartLocation)
if path != None: if path != None:
AreaOpen[1] = check AreaOpen[area] = tunnel2
if AreaOpen[2] == None:
check = 'S2-00' check_sector(1, 'S1-00', 'S1-6B', 'S1-68')
path = graph.get_path(StartLocation, check) check_sector(2, 'S2-00', 'S2-7F', 'S2-82')
if path != None: check_sector(3, 'S3-00', 'S3-56', 'S3-59')
path = graph.get_path(check, StartLocation) check_sector(4, 'S4-00', 'S4-6A', 'S4-6C')
if path != None:
AreaOpen[2] = check
if ScrewAttack:
if AreaOpen[2] == None:
check = 'S2-7F'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[2] = check
if AreaOpen[2] == None:
check = 'S2-82'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[2] = check
if AreaOpen[3] == None:
check = 'S3-00'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[3] = check
if ScrewAttack:
if AreaOpen[3] == None:
check = 'S3-56'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[3] = check
if AreaOpen[3] == None:
check = 'S3-59'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[3] = check
if AreaOpen[4] == None:
check = 'S4-00'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[4] = check
if ScrewAttack:
if AreaOpen[4] == None:
check = 'S4-6A'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[4] = check
if AreaOpen[4] == None:
check = 'S4-6C'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[4] = check
if AreaOpen[5] == None: if AreaOpen[5] == None:
check = 'S5-00' check = 'S5-00'
path = graph.get_path(StartLocation, check) path = graph.get_path(StartLocation, check)
@ -1736,28 +1675,9 @@ def find_available_areas(graph):
path = graph.get_path(check, StartLocation) path = graph.get_path(check, StartLocation)
if path != None: if path != None:
AreaOpen[5] = check AreaOpen[5] = check
if AreaOpen[6] == None:
check = 'S6-00' check_sector(6, 'S6-00', 'S6-51', 'S6-54')
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[6] = check
if ScrewAttack:
if AreaOpen[6] == None:
check = 'S6-51'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[6] = check
if AreaOpen[6] == None:
check = 'S6-54'
path = graph.get_path(StartLocation, check)
if path != None:
path = graph.get_path(check, StartLocation)
if path != None:
AreaOpen[6] = check
if BlueDoors == False: if BlueDoors == False:
path = graph.get_path(StartLocation, 'Security-Level-1', depth=250) path = graph.get_path(StartLocation, 'Security-Level-1', depth=250)
if path != None: if path != None: