Skip to content

Commit

Permalink
Fix valid actions in gym
Browse files Browse the repository at this point in the history
  • Loading branch information
msosav committed Aug 1, 2024
1 parent fb8e102 commit 9186540
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions config/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit 9186540

Please sign in to comment.