[rllib] Fix multiagent example crash due to undefined abstract method (#7329)

* fix multiagent example

* 0 workers
This commit is contained in:
Eric Liang
2020-02-26 22:54:41 -08:00
committed by GitHub
parent 219180b580
commit 58073f7260
3 changed files with 15 additions and 3 deletions
+8
View File
@@ -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,
-1
View File
@@ -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,