forked from starry-sky6688/MARL-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (37 loc) · 1.55 KB
/
main.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
35
36
37
38
39
from runner import Runner
from smac.env import StarCraft2Env
from common.arguments import get_common_args, get_coma_args, get_mixer_args, get_centralv_args, get_reinforce_args, get_commnet_args, get_g2anet_args
if __name__ == '__main__':
for i in range(8):
args = get_common_args()
if args.alg.find('coma') > -1:
args = get_coma_args(args)
elif args.alg.find('central_v') > -1:
args = get_centralv_args(args)
elif args.alg.find('reinforce') > -1:
args = get_reinforce_args(args)
else:
args = get_mixer_args(args)
if args.alg.find('commnet') > -1:
args = get_commnet_args(args)
if args.alg.find('g2anet') > -1:
args = get_g2anet_args(args)
env = StarCraft2Env(map_name=args.map,
step_mul=args.step_mul,
difficulty=args.difficulty,
game_version=args.game_version,
replay_dir=args.replay_dir)
env_info = env.get_env_info()
args.n_actions = env_info["n_actions"]
args.n_agents = env_info["n_agents"]
args.state_shape = env_info["state_shape"]
args.obs_shape = env_info["obs_shape"]
args.episode_limit = env_info["episode_limit"]
runner = Runner(env, args)
if not args.evaluate:
runner.run(i)
else:
win_rate, _ = runner.evaluate()
print('The win rate of {} is {}'.format(args.alg, win_rate))
break
env.close()