Game image differs after saving and loading state
DavidSteinhart opened this issue · 4 comments
DavidSteinhart commented
I tried saving and loading a state, but the resulting images differ. Mario shows a different animation frame. Might be related to #99
from pyboy.utils import WindowEvent
import pyboy as pyboy
import numpy as np
import io
# Load Super Mario Land and progress to start of game
boy = pyboy.PyBoy('SuperMarioLand1.gb')
boy.set_emulation_speed(0)
for i in range(100):
boy.tick()
boy.send_input(WindowEvent.PRESS_BUTTON_START)
boy.tick()
boy.send_input(WindowEvent.RELEASE_BUTTON_START)
for i in range(20):
boy.tick()
boy.send_input(WindowEvent.PRESS_ARROW_RIGHT)
for i in range(50):
boy.tick()
screen_before = boy.botsupport_manager().screen().screen_image()
array_before = boy.botsupport_manager().screen().screen_ndarray()
file_like_object = io.BytesIO()
boy.save_state(file_like_object)
file_like_object.seek(0)
boy.load_state(file_like_object)
screen_after = boy.botsupport_manager().screen().screen_image()
array_after = boy.botsupport_manager().screen().screen_ndarray()
screen_before.show()
screen_after.show()
print(np.array_equal(array_before, array_after)) # False
DavidSteinhart commented
The two states seem to synchronize again after calling boy.tick() once.
Baekalfen commented
It's likely just the screen which needs to be flushed. Definitely a bug, just a hint, if someone wants to help me fix it
201512130144 commented
the more more ,the less less
krs013 commented
This appears to have been fixed in 1.4. The test code returns True and the images shown match.