Skip to content

Commit

Permalink
Fix bug causing infinite loop in assumed fill
Browse files Browse the repository at this point in the history
  • Loading branch information
mike8699 committed Oct 1, 2023
1 parent 4061bab commit f3b8706
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ph_rando/shuffler/_shuffler.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def generate(self: Self) -> ShufflerAuxData:
check.contents = None # type: ignore

while True:
# Save shallow copy of original list so we can restart if the assumed fill fails
backup_item_pool = item_pool.copy()

random.shuffle(item_pool)

try:
Expand All @@ -210,8 +213,8 @@ def generate(self: Self) -> ShufflerAuxData:
for room in area.rooms:
for check in room.chests:
if check.contents is not None and check not in self._checks_to_exclude:
item_pool.append(check.contents)
check.contents = None # type: ignore
item_pool = backup_item_pool
continue

return self.aux_data
Expand Down

0 comments on commit f3b8706

Please sign in to comment.