Base Env Class¶
- class xuance.environment.utils.base.RawEnvironment(*args, **kwargs)[源代码]¶
基类:
ABCA base class for new environment.
- The following attributes are necessary when creating a new environment:
self.env: the environment object;
self.observation_space: the observation space of the agent;
self.action_space: the action space of the agent;
self.max_episode_steps: the maximum steps for one episode of the environment in XuanCe.
- abstract render(*args, **kwargs)[源代码]¶
Renders the environment.
- 返回:
The images used to visualize the environment.
- 返回类型:
rgb_images (np.ndarray or list)
- abstract reset(**kwargs)[源代码]¶
Resets the environment with kwargs.
- 返回:
The initial observations of the agent. info (dict): The information about the environment.
- 返回类型:
observation (np.ndarray or list)
- abstract step(action)[源代码]¶
Steps through the environment with action.
- 参数:
action (np.ndarray or list) – The action to be executed.
- 返回:
The next step observation after executing action. reward (np.ndarray or list): The reward returned by the environment. terminated(np.ndarray or list): A bool value that indicates if the environment should be terminated. truncated(np.ndarray or list): A bool value that indicates if the environment should be truncated. info (dict): The information about the environment.
- 返回类型:
observation (np.ndarray or list)
- class xuance.environment.utils.base.RawMultiAgentEnv(*args, **kwargs)[源代码]¶
基类:
ABCA base class for multi-agent environment.
- The following attributes are necessary when creating a new multi-agent environment in XuanCe:
self.env: the environment object;
self.observation_space: the observation space of the agent;
self.action_space: the action space of the agent;
self.agents: a list of all agents’ ids;
self.num_agents: the number of total agents in the environment;
self.groups: a list of groups. Each group contains agents’ ids with a same role;
self.num_groups: the number of groups of the environment, default is 1;
self.max_episode_steps: the maximum steps for one episode of the environment.
- abstract render(*args, **kwargs)[源代码]¶
Renders the environment.
- 返回:
The images used to visualize the environment.
- 返回类型:
rgb_images (np.ndarray or list)
- abstract reset(**kwargs)[源代码]¶
Resets the environment with kwargs.
- 返回:
The initial observations of the agent. info (MultiAgentDict): The information about the environment.
- 返回类型:
observation (MultiAgentDict)
- abstract step(action_dict: Dict[Any, Any]) Tuple[Dict[Any, Any], Dict[Any, Any], Dict[Any, Any], bool, Dict[Any, Any]][源代码]¶
Steps through the environment with action.
- 参数:
action_dict (MultiAgentDict) – A dict that contains all agents’ actions.
- 返回:
The next step observations after executing actions. reward (MultiAgentDict): The rewards returned by the environment. terminated(MultiAgentDict): A dict of bool values that indicates if the environment should be terminated. truncated(bool): A bool value that indicates if the environment should be truncated. info (MultiAgentDict): The information about the environment.
- 返回类型:
observation (MultiAgentDict)