Commit 0ec6ecee authored by jameskrw's avatar jameskrw
Browse files

updated frozenlake

parent 17016b81
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ from typing import Optional, List, Union
@dataclass
class FrozenLakeConfig(BaseConfig):
    desc: Optional[List[str]] = None  # environment map
    is_slippery: bool = False
    is_slippery: bool = True
    size: int = 4
    p: float = 0.8  # probability of frozen tile
    render_mode: str = "vision"  # "text" or "vision"
+3 −10
Original line number Diff line number Diff line
@@ -59,20 +59,11 @@ class FrozenLakeEnv(BaseEnv):
        """Reset the environment with seed"""
        with NoLoggerWarnings():
            with set_seed(seed):
                if self.config.desc is None:
                    random_map = generate_random_map(
                        size=self.config.size, 
                        p=self.config.p, 
                        seed=seed
                    )
                    self.gym_env.desc = np.asarray(random_map, dtype="c")
                self.gym_env.reset(seed=seed)
        
        self.total_reward = 0
        return self._render(init_obs=True), {}

    def step(self, action_str: str):
        """Take a step in the environment"""
        rst = parse_llm_raw_response(
            response=action_str,
            special_token_list=self.config.special_token_list,
@@ -98,9 +89,11 @@ class FrozenLakeEnv(BaseEnv):
        for action in action_list:
            if action in self.ACTION_LOOKUP:
                action_int = self.ACTION_LOOKUP[action]
                _, step_reward, done, _, _ = self.gym_env.step(action_int)
                _, step_reward, terminated, _, _ = self.gym_env.step(action_int)
                self.reward += step_reward
                self.valid_actions.append(action)
                done=self._finished()
                assert terminated == done
                if done:
                    if self._success():
                        metrics['success'] = True