Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix docs tictacto dummy vector env #669 #749

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/tutorials/tictactoe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ With the above preparation, we are close to the first learned agent. The followi
agent_opponent: Optional[BasePolicy] = None,
) -> None:
env = get_env()
env = DummyVectorEnv([lambda: env])
Copy link
Collaborator

@Trinkle23897 Trinkle23897 Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In collector, it will automatically wrap the single instance env to vector env, see

if isinstance(env, gym.Env) and not hasattr(env, "__len__"):
warnings.warn("Single environment detected, wrap to DummyVectorEnv.")
self.env = DummyVectorEnv([lambda: env]) # type: ignore

So you should modify this line instead of documentation to

        if isinstance(env, (gym.Env, PettingZooEnv)) and not hasattr(env, "__len__"):

policy, optim, agents = get_agents(
args, agent_learn=agent_learn, agent_opponent=agent_opponent
)
Expand Down