-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (34 loc) · 1.1 KB
/
Copy pathmain.py
File metadata and controls
43 lines (34 loc) · 1.1 KB
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
40
41
42
43
""" Packaged MASAC """
import argparse
import torch
import numpy as np
from unityagents import UnityEnvironment
from agents.dqn_agent import DQNAgent
from agents.sac_agent import SacAgent
from agents.masac_agent import MaSacAgent
def seed_torch(seed):
torch.manual_seed = seed
if torch.backends.cudnn.enabled:
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
def main():
env = UnityEnvironment(file_name="TennisEnvironment/Tennis.app")
seed = 777
np.random.seed(seed)
seed_torch(seed)
num_episode = 1000
memory_size = 10000
batch_size = 64
agent = MaSacAgent(env, memory_size, batch_size)
agent.train(num_episode)
agent.test()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Train Rl algorithms')
parser.add_argument('-m', '--mode', type= str, default="multiagent",
choices=["multiagent"],
help='determines which algorithm to train')
args = parser.parse_args()
if args.mode == "multiagent":
main()
else:
main()