Skip to content

Commit

Permalink
#20, #22 -- I think these are the only places where the input needs t…
Browse files Browse the repository at this point in the history
…o be set
  • Loading branch information
etosch committed Sep 22, 2018
1 parent e7d1768 commit a990add
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions openai/toybox/toybox/envs/atari/breakout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
class BreakoutEnv(ToyboxBaseEnv):

def __init__(self, grayscale=True, alpha=False):
self._breakout_action_strs = [NOOP_STR, LEFT_STR, RIGHT_STR, FIRE_STR]
super().__init__(Toybox('breakout', grayscale),
grayscale=grayscale,
alpha=alpha,
actions=[NOOP_ID, LEFT_ID, RIGHT_ID])
actions=[ACTION_LOOKUP[s] for s in self._breakout_action_strs])

def _action_to_input(self, action):
input = Input()
if action == NOOP_STR or action == NOOP_ID:
action = action if type(action) == str else ACTION_MEANING[action]
if action == NOOP_STR:
return input
elif action == RIGHT_STR or action == RIGHT_ID:
elif action == RIGHT_STR:
input.set_input(RIGHT_STR)
elif action == LEFT_STR or action == LEFT_ID:
elif action == LEFT_STR:
input.set_input(LEFT_STR)
elif action == FIRE_STR:
input.set_input(NOOP_STR, button=BUTTON1_STR)
else:
action = action if type(action) == str \
else ACTION_ID_TO_STR_LOOKUP[action]
raise ValueError('Unsupported action: %s' % action)
return input

0 comments on commit a990add

Please sign in to comment.