Skip to content

Commit

Permalink
feature(zjow): add agent configurations & polish replay video saving …
Browse files Browse the repository at this point in the history
…methods (#184)

* Add muzero config

* polish atari env replay code

* add more variant muzero agents

* add more variant muzero agents

* polish setup

* Add tictactoe

* polish render of pendulum

* polish muzero breakout config

* Add efficientzero config

* Add efficientzero config

* polish atari env replay

* polish code

* add sampled efficientzero config

* add sampled efficientzero config

* add sampled efficientzero config

* Add gomoku & tictactow Agent config

* polish config

* change env_name in config into env_id
  • Loading branch information
zjowowen authored Feb 8, 2024
1 parent 541f5bf commit eb8594c
Show file tree
Hide file tree
Showing 129 changed files with 4,676 additions and 303 deletions.
6 changes: 3 additions & 3 deletions docs/source/tutorials/envs/customize_envs.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ class LightZeroEnvWrapper(gym.Wrapper):
Specifically, use the following function to wrap a gym environment into the format required by LightZero using `LightZeroEnvWrapper`. The `get_wrappered_env` function returns an anonymous function that generates a `DingEnvWrapper` instance each time it is called. This instance takes `LightZeroEnvWrapper` as an anonymous function and internally wraps the original environment into the format required by LightZero.

```python
def get_wrappered_env(wrapper_cfg: EasyDict, env_name: str):
def get_wrappered_env(wrapper_cfg: EasyDict, env_id: str):
# overview comments
...
if wrapper_cfg.manually_discretization:
return lambda: DingEnvWrapper(
gym.make(env_name),
gym.make(env_id),
cfg={
'env_wrapper': [
lambda env: ActionDiscretizationEnvWrapper(env, wrapper_cfg), lambda env:
Expand All @@ -218,7 +218,7 @@ def get_wrappered_env(wrapper_cfg: EasyDict, env_name: str):
)
else:
return lambda: DingEnvWrapper(
gym.make(env_name), cfg={'env_wrapper': [lambda env: LightZeroEnvWrapper(env, wrapper_cfg)]}
gym.make(env_id), cfg={'env_wrapper': [lambda env: LightZeroEnvWrapper(env, wrapper_cfg)]}
)
```

Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorials/envs/customize_envs_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ class LightZeroEnvWrapper(gym.Wrapper):
具体使用时,使用下面的函数,将一个 gym 环境,通过 `LightZeroEnvWrapper` 包装成 LightZero 所需要的环境格式。 `get_wrappered_env` 会返回一个匿名函数,该匿名函数每次调用都会产生一个 `DingEnvWrapper` 实例,该实例会将 `LightZeroEnvWrapper` 作为匿名函数传入,并在实例内部将原始环境封装成 LightZero 所需的格式。

```Python
def get_wrappered_env(wrapper_cfg: EasyDict, env_name: str):
def get_wrappered_env(wrapper_cfg: EasyDict, env_id: str):
# overview comments
...
if wrapper_cfg.manually_discretization:
return lambda: DingEnvWrapper(
gym.make(env_name),
gym.make(env_id),
cfg={
'env_wrapper': [
lambda env: ActionDiscretizationEnvWrapper(env, wrapper_cfg), lambda env:
Expand All @@ -231,7 +231,7 @@ def get_wrappered_env(wrapper_cfg: EasyDict, env_name: str):
)
else:
return lambda: DingEnvWrapper(
gym.make(env_name), cfg={'env_wrapper': [lambda env: LightZeroEnvWrapper(env, wrapper_cfg)]}
gym.make(env_id), cfg={'env_wrapper': [lambda env: LightZeroEnvWrapper(env, wrapper_cfg)]}
)
```

Expand Down
5 changes: 5 additions & 0 deletions lzero/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .alphazero import AlphaZeroAgent
from .efficientzero import EfficientZeroAgent
from .gumbel_muzero import GumbelMuZeroAgent
from .muzero import MuZeroAgent
from .sampled_alphazero import SampledAlphaZeroAgent
from .sampled_efficientzero import SampledEfficientZeroAgent
Loading

0 comments on commit eb8594c

Please sign in to comment.