mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 04:00:44 +08:00
[rllib] Fix multiagent example crash due to undefined abstract method (#7329)
* fix multiagent example * 0 workers
This commit is contained in:
@@ -1264,6 +1264,14 @@ py_test(
|
||||
args = ["--num-cpus=4"]
|
||||
)
|
||||
|
||||
py_test(
|
||||
name = "examples/rock_paper_scissors_multiagent", main = "examples/rock_paper_scissors_multiagent.py",
|
||||
tags = ["examples", "examples_R"],
|
||||
size = "large",
|
||||
srcs = ["examples/rock_paper_scissors_multiagent.py"],
|
||||
args = ["--stop=200"],
|
||||
)
|
||||
|
||||
py_test(
|
||||
name = "examples/twostep_game_maddpg", main = "examples/twostep_game.py",
|
||||
tags = ["examples", "examples_T"],
|
||||
|
||||
@@ -7,6 +7,7 @@ This demonstrates running the following policies in competition:
|
||||
(4) LSTM policy with custom entropy loss
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import random
|
||||
from gym.spaces import Discrete
|
||||
|
||||
@@ -23,6 +24,9 @@ ROCK = 0
|
||||
PAPER = 1
|
||||
SCISSORS = 2
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--stop", type=int, default=400000)
|
||||
|
||||
|
||||
class RockPaperScissorsEnv(MultiAgentEnv):
|
||||
"""Two-player environment for rock paper scissors.
|
||||
@@ -153,13 +157,14 @@ def run_heuristic_vs_learned(use_lstm=False, trainer="PG"):
|
||||
else:
|
||||
return random.choice(["always_same", "beat_last"])
|
||||
|
||||
args = parser.parse_args()
|
||||
tune.run(
|
||||
trainer,
|
||||
stop={"timesteps_total": 400000},
|
||||
stop={"timesteps_total": args.stop},
|
||||
config={
|
||||
"env": RockPaperScissorsEnv,
|
||||
"gamma": 0.9,
|
||||
"num_workers": 4,
|
||||
"num_workers": 0,
|
||||
"num_envs_per_worker": 4,
|
||||
"sample_batch_size": 10,
|
||||
"train_batch_size": 200,
|
||||
|
||||
@@ -164,7 +164,6 @@ class Policy(metaclass=ABCMeta):
|
||||
return action, [s[0] for s in state_out], \
|
||||
{k: v[0] for k, v in info.items()}
|
||||
|
||||
@abstractmethod
|
||||
@DeveloperAPI
|
||||
def compute_log_likelihoods(self,
|
||||
actions,
|
||||
|
||||
Reference in New Issue
Block a user