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

View File

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