From 976b36d87bed4400ce058c43931ebab2949c2641 Mon Sep 17 00:00:00 2001 From: Jiayi Weng Date: Mon, 28 Nov 2022 15:00:38 -0800 Subject: [PATCH] Add use_fire_reset option in atari env (#223) close #221 --- docs/env/atari.rst | 3 +++ envpool/atari/atari_env.h | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/env/atari.rst b/docs/env/atari.rst index 654f55a1..88754a77 100644 --- a/docs/env/atari.rst +++ b/docs/env/atari.rst @@ -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 ----------------- diff --git a/envpool/atari/atari_env.h b/envpool/atari/atari_env.h index 4d71570e..bca85d13 100644 --- a/envpool/atari/atari_env.h +++ b/envpool/atari/atari_env.h @@ -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)); } @@ -126,9 +127,12 @@ class AtariEnv : public Env { 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