make itemLocations a set

should speed up get_path somewhat
wip-faster-paths
magical 2024-02-07 19:35:08 -08:00
parent cbb85e3baa
commit 6194d555b8
2 changed files with 8 additions and 12 deletions

View File

@ -26,7 +26,7 @@ class Game:
self.queue = list()
self.majorItemLocations = list()
self.minorItemLocations = list()
self.itemLocations = list()
self.itemLocations = set()
self.patcher = dict()
self.graph.clear()
self.areaConnections.clear()
@ -182,29 +182,25 @@ class Game:
def add_to_majors(self, item):
if item not in self.itemLocations:
self.itemLocations.append(item)
self.itemLocations.add(item)
if item not in self.majorItemLocations:
self.majorItemLocations.append(item)
def add_list_to_majors(self, locations):
for item in locations:
if item not in self.itemLocations:
self.itemLocations.append(item)
self.itemLocations.add(item)
if item not in self.majorItemLocations:
self.majorItemLocations.append(item)
def add_to_minors(self, item):
if item not in self.itemLocations:
self.itemLocations.append(item)
self.itemLocations.add(item)
if item not in self.minorItemLocations:
self.minorItemLocations.append(item)
def add_list_to_minors(self, locations):
for item in locations:
if item not in self.itemLocations:
self.itemLocations.append(item)
self.itemLocations.add(item)
if item not in self.minorItemLocations:
self.minorItemLocations.append(item)

View File

@ -2928,9 +2928,9 @@ def patch_game():
itemProgression.update({ UsedLocations[x]: PlacedItems[x] })
spoilerLog.update({ 'Item order': itemProgression })
itemDict = dict()
World.itemLocations.sort()
for x in range(0, len(World.itemLocations)):
itemDict.update({ World.itemLocations[x]: 0 })
itemLocations = sorted(World.itemLocations)
for x in range(0, len(itemLocations)):
itemDict.update({ itemLocations[x]: 0 })
for x in range(0, len(PlacedItems)):
itemDict.update({ UsedLocations[x]: PlacedItems[x] })
spoilerLog.update({ 'Items': itemDict })