Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super Metroid: Avoid unnecessary deep copies to improve generation speed. #4130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions worlds/sm/variaRandomizer/logic/smboolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ..utils.doorsmanager import DoorsManager
from ..utils.objectives import Objectives
from ..utils.parameters import Knows, isKnows
import copy
import logging
import sys

Expand Down Expand Up @@ -240,6 +241,17 @@ def energyReserveCountOk(self, count, difficulty=0):
return SMBool(True, difficulty, items = [items])
else:
return smboolFalse

def __deepcopy__(self, memo=None):
cls = self.__class__
cp = cls.__new__(cls)
if memo is None:
memo = {}
memo[id(self)] = cp
for k, v in self.__dict__.items():
setattr(cp, k, copy.deepcopy(v, memo))
return cp


class SMBoolManagerPlando(SMBoolManager):
def __init__(self):
Expand Down
10 changes: 10 additions & 0 deletions worlds/sm/variaRandomizer/utils/objectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,13 @@ def writeChar(c, frameDelay=2):
# write trailer, see intro_text.asm
rom.writeWord(0xAE5B)
rom.writeWord(0x9698)

def __deepcopy__(self, memo=None):
cls = self.__class__
cp = cls.__new__(cls)
if memo is None:
memo = {}
memo[id(self.graph)] = self.graph
for k, v in self.__dict__.items():
setattr(cp, k, copy.deepcopy(v, memo))
return cp
Loading