Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform fire on reset after doing no-ops, make fire_on_reset configurable #158

Merged
merged 3 commits into from
Jun 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion rlpyt/envs/atari/atari_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self,
num_img_obs=4, # Number of (past) frames in observation (>=1).
clip_reward=True,
episodic_lives=True,
fire_on_reset=False,
max_start_noops=30,
repeat_action_probability=0.,
horizon=27000,
Expand Down Expand Up @@ -108,6 +109,8 @@ def reset(self):
self._life_reset()
for _ in range(np.random.randint(0, self._max_start_noops + 1)):
self.ale.act(0)
if self._fire_on_reset:
self.fire_and_up()
self._update_obs() # (don't bother to populate any frame history)
self._step_counter = 0
return self.get_obs()
Expand Down Expand Up @@ -174,12 +177,15 @@ def _check_life(self):

def _life_reset(self):
self.ale.act(0) # (advance from lost life state)
self._lives = self.ale.lives()

def fire_and_up(self):
if self._has_fire:
# TODO: for sticky actions, make sure fire is actually pressed
self.ale.act(1) # (e.g. needed in Breakout, not sure what others)
if self._has_up:
self.ale.act(2) # (not sure if this is necessary, saw it somewhere)
self._lives = self.ale.lives()


###########################################################################
# Properties
Expand Down