Envs

class lzero.envs.wrappers.lightzero_env_wrapper.LightZeroEnvWrapper(env, cfg: EasyDict)[source]

Bases: object

Overview:

Package the classic_control, box2d environment into the format required by LightZero. Wrap obs as a dict, containing keys: obs, action_mask and to_play.

Interface:

__init__, reset, step

Properties:
  • env: the environment to wrap.

__init__(env, cfg: EasyDict) → None[source]
Overview:

Initialize self. See help(type(self)) for accurate signature; setup the properties according to running mean and std.

Parameters:

env (-) – the environment to wrap.

reset(**kwargs)[source]
Overview:

Resets the state of the environment and reset properties.

Parameters:

kwargs (-) – Reset with this key argumets

Returns:

New observation after reset

Return type:

  • observation (Any)

step(action)[source]
Overview:

Step the environment with the given action. Repeat action, sum reward, and update data_count, and also update the self.rms property once after integrating with the input action.

Parameters:

action (-) – the given action to step with.

Returns:

normalized observation after the input action and updated self.rms - reward (Any) : amount of reward returned after previous action - done (Bool) : whether the episode has ended, in which case further step() calls will return undefined results - info (Dict) : contains auxiliary diagnostic information (helpful for debugging, and sometimes learning)

Return type:

  • self.observation(observation)

class lzero.envs.wrappers.action_discretization_env_wrapper.ActionDiscretizationEnvWrapper(env, cfg: EasyDict)[source]

Bases: object

Overview:

The modified environment with manually discretized action space. For each dimension, equally dividing the original continuous action into each_dim_disc_size bins and using their Cartesian product to obtain handcrafted discrete actions.

Interface:

__init__, reset, step

Properties:
  • env: the environment to wrap.

__init__(env, cfg: EasyDict) → None[source]
Overview:

Initialize self. See help(type(self)) for accurate signature; setup the properties according to running mean and std.

Parameters:

env (-) – the environment to wrap.

reset(**kwargs)[source]
Overview:

Resets the state of the environment and reset properties.

Parameters:

kwargs (-) – Reset with this key argumets

Returns:

New observation after reset

Return type:

  • observation (Any)

step(action)[source]
Overview:

Step the environment with the given action. Repeat action, sum reward, and update data_count, and also update the self.rms property once after integrating with the input action.

Parameters:

action (-) – the given action to step with.

Returns:

normalized observation after the input action and updated self.rms - reward (Any) : amount of reward returned after previous action - done (Bool) : whether the episode has ended, in which case further step() calls will return undefined results - info (Dict) : contains auxiliary diagnostic information (helpful for debugging, and sometimes learning)

Return type:

  • self.observation(observation)