-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.py
34 lines (28 loc) · 1.12 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# --------------------------------------------------------------------------------------------------
# @file: run.py
# @brief: This script is used for running self-play experiments by providing a configuration file.
# Example usage: python run.py --exp path/to/config.json
# --------------------------------------------------------------------------------------------------
import argparse
import json
import os
def run(exp: str) -> None:
assert os.path.exists(exp), f"File {exp} does not exist!"
# load the configuration files
config = json.load(open(exp))
play = config['setting']
if play == "multiagent":
from self_play.multi_agent import MultiAgent as SelfPlay
else:
raise NotImplementedError(f"Self play of type {play} is not supported!")
game = SelfPlay(config)
game.play()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
'--exp',
default='./config/sorts/2agents.json',
type=str,
help='path to experiment configuration file')
args = parser.parse_args()
run(**vars(args))