diff --git a/nes_py/nes_env.py b/nes_py/nes_env.py index cd239b6..78df429 100644 --- a/nes_py/nes_env.py +++ b/nes_py/nes_env.py @@ -150,7 +150,7 @@ def __init__(self, rom_path, # setup a placeholder for a 'human' render mode viewer self.viewer = None # setup a placeholder for a pointer to a backup state - self._backup_env = None + self._has_backup = False # setup the NumPy screen from the C++ vector self.screen = None self.ram = None @@ -203,6 +203,7 @@ def _frame_advance(self, action): def _backup(self): """Backup the NES state in the emulator.""" _LIB.Backup(self._env) + self._has_backup = True def _restore(self): """Restore the backup state into the NES emulator.""" @@ -225,7 +226,7 @@ def reset(self): # call the before reset callback self._will_reset() # reset the emulator - if self._backup_env is not None: + if self._has_backup: self._restore() else: _LIB.Reset(self._env)