Skip to content

Commit

Permalink
fix backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kautenja committed Jan 6, 2019
1 parent d2de6bf commit 3b7f92f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nes_py/nes_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand All @@ -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)
Expand Down

0 comments on commit 3b7f92f

Please sign in to comment.