From 91865403879050bb30e4434c889e3030959a3ff4 Mon Sep 17 00:00:00 2001 From: Miguel Sosa <85181687+msosav@users.noreply.github.com.> Date: Thu, 1 Aug 2024 13:05:10 -0500 Subject: [PATCH] Fix valid actions in gym --- config/gym.py | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/config/gym.py b/config/gym.py index a5b5510..7427cc4 100644 --- a/config/gym.py +++ b/config/gym.py @@ -25,26 +25,8 @@ def __init__(self, config: dict, debug=False): if not self.debug: self.pyboy.set_emulation_speed(0) - self.valid_actions = [ - WindowEvent.PRESS_ARROW_DOWN, - WindowEvent.PRESS_ARROW_LEFT, - WindowEvent.PRESS_ARROW_RIGHT, - WindowEvent.PRESS_ARROW_UP, - WindowEvent.PRESS_BUTTON_A, - WindowEvent.PRESS_BUTTON_B, - ] - - self.release_arrow = [ - WindowEvent.RELEASE_ARROW_DOWN, - WindowEvent.RELEASE_ARROW_LEFT, - WindowEvent.RELEASE_ARROW_RIGHT, - WindowEvent.RELEASE_ARROW_UP - ] - - self.release_button = [ - WindowEvent.RELEASE_BUTTON_A, - WindowEvent.RELEASE_BUTTON_B - ] + self.valid_actions = ['', 'a', 'b', 'left', 'right', + 'up', 'down', 'start', 'select'] self.observation_space = spaces.Box( low=0, high=255, shape=(16, 20), dtype=np.uint8) @@ -59,7 +41,7 @@ def step(self, action): if action == 0: pass else: - self.pyboy.send_input(self.valid_actions[action]) + self.pyboy.button(self.valid_actions[action]) self.pyboy.tick()