这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix exception with watching pistonball environments #663

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

Merged
merged 1 commit into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions test/pettingzoo/pistonball.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os
import warnings
from typing import List, Optional, Tuple

import gym
Expand Down Expand Up @@ -177,6 +178,12 @@ def watch(
args: argparse.Namespace = get_args(), policy: Optional[BasePolicy] = None
) -> None:
env = DummyVectorEnv([get_env])
if not policy:
warnings.warn(
"watching random agents, as loading pre-trained policies is "
"currently not supported"
)
policy, _, _ = get_agents(args)
policy.eval()
[agent.set_eps(args.eps_test) for agent in policy.policies.values()]
collector = Collector(policy, env, exploration_noise=True)
Expand Down
7 changes: 7 additions & 0 deletions test/pettingzoo/pistonball_continuous.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os
import warnings
from typing import Any, Dict, List, Optional, Tuple, Union

import gym
Expand Down Expand Up @@ -269,6 +270,12 @@ def watch(
args: argparse.Namespace = get_args(), policy: Optional[BasePolicy] = None
) -> None:
env = DummyVectorEnv([get_env])
if not policy:
warnings.warn(
"watching random agents, as loading pre-trained policies is "
"currently not supported"
)
policy, _, _ = get_agents(args)
policy.eval()
collector = Collector(policy, env)
result = collector.collect(n_episode=1, render=args.render)
Expand Down