Skip to content

Commit

Permalink
Perform fire on reset after doing no-ops, make fire_on_reset configur…
Browse files Browse the repository at this point in the history
…able (astooke#158)

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

* Fix typo

* Set fire_on_reset to be False by default
  • Loading branch information
ankeshanand authored and jordan-schneider committed Jan 4, 2021
1 parent b3c63a5 commit f6a479a
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit f6a479a

Please sign in to comment.