Fix issue around reset
This commit is contained in:
@@ -417,7 +417,7 @@ class PrimaiteGame:
|
|||||||
agent_settings=agent_settings,
|
agent_settings=agent_settings,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
msg(f"Configuration error: {agent_type} is not a valid agent type.")
|
msg = f"Configuration error: {agent_type} is not a valid agent type."
|
||||||
_LOGGER.error(msg)
|
_LOGGER.error(msg)
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
game.agents[agent_cfg["ref"]] = new_agent
|
game.agents[agent_cfg["ref"]] = new_agent
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import json
|
import json
|
||||||
from typing import Any, Dict, Optional, SupportsFloat, Tuple
|
from typing import Any, Dict, Optional, SupportsFloat, Tuple
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ class PrimaiteGymEnv(gymnasium.Env):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.game_config: Dict = game_config
|
self.game_config: Dict = game_config
|
||||||
"""PrimaiteGame definition. This can be changed between episodes to enable curriculum learning."""
|
"""PrimaiteGame definition. This can be changed between episodes to enable curriculum learning."""
|
||||||
self.game: PrimaiteGame = PrimaiteGame.from_config(self.game_config)
|
self.game: PrimaiteGame = PrimaiteGame.from_config(copy.deepcopy(self.game_config))
|
||||||
"""Current game."""
|
"""Current game."""
|
||||||
self._agent_name = next(iter(self.game.rl_agents))
|
self._agent_name = next(iter(self.game.rl_agents))
|
||||||
"""Name of the RL agent. Since there should only be one RL agent we can just pull the first and only key."""
|
"""Name of the RL agent. Since there should only be one RL agent we can just pull the first and only key."""
|
||||||
@@ -78,7 +79,7 @@ class PrimaiteGymEnv(gymnasium.Env):
|
|||||||
f"Resetting environment, episode {self.episode_counter}, "
|
f"Resetting environment, episode {self.episode_counter}, "
|
||||||
f"avg. reward: {self.agent.reward_function.total_reward}"
|
f"avg. reward: {self.agent.reward_function.total_reward}"
|
||||||
)
|
)
|
||||||
self.game: PrimaiteGame = PrimaiteGame.from_config(cfg=self.game_config)
|
self.game: PrimaiteGame = PrimaiteGame.from_config(cfg=copy.deepcopy(self.game_config))
|
||||||
self.game.setup_for_episode(episode=self.episode_counter)
|
self.game.setup_for_episode(episode=self.episode_counter)
|
||||||
self.episode_counter += 1
|
self.episode_counter += 1
|
||||||
state = self.game.get_sim_state()
|
state = self.game.get_sim_state()
|
||||||
|
|||||||
Reference in New Issue
Block a user