Skip to content

Commit

Permalink
Add use_fire_reset option in atari env (#223)
Browse files Browse the repository at this point in the history
close #221
  • Loading branch information
Trinkle23897 authored Nov 28, 2022
1 parent e2e71fd commit 976b36d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/env/atari.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Options
result);
* ``use_inter_area_resize (bool)``: whether to use ``cv::INTER_AREA`` for
image resize, default to ``True``.
* ``use_fire_reset (bool)``: whether to use ``fire-reset`` wrapper, default to
``True``.


Observation Space
-----------------
Expand Down
14 changes: 9 additions & 5 deletions envpool/atari/atari_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class AtariEnvFns {
return MakeDict(
"stack_num"_.Bind(4), "frame_skip"_.Bind(4), "noop_max"_.Bind(30),
"zero_discount_on_life_loss"_.Bind(false), "episodic_life"_.Bind(false),
"reward_clip"_.Bind(false), "img_height"_.Bind(84),
"img_width"_.Bind(84), "task"_.Bind(std::string("pong")),
"reward_clip"_.Bind(false), "use_fire_reset"_.Bind(true),
"img_height"_.Bind(84), "img_width"_.Bind(84),
"task"_.Bind(std::string("pong")),
"repeat_action_probability"_.Bind(0.0f),
"use_inter_area_resize"_.Bind(true), "gray_scale"_.Bind(true));
}
Expand Down Expand Up @@ -126,9 +127,12 @@ class AtariEnv : public Env<AtariEnvSpec> {
env_->setInt("random_seed", seed_);
env_->loadROM(rom_path_);
action_set_ = env_->getMinimalActionSet();
for (auto a : action_set_) {
if (a == 1) {
fire_reset_ = true;
if (spec.config["use_fire_reset"_]) {
// https://github.com/sail-sg/envpool/issues/221
for (auto a : action_set_) {
if (a == 1) {
fire_reset_ = true;
}
}
}
// init buf
Expand Down

0 comments on commit 976b36d

Please sign in to comment.