-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
44 lines (33 loc) · 1.1 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
40
41
42
43
44
# main.py
# runs the simulation
import argparse
from tqdm import trange
from agent_torch.core import Registry, Runner
from agent_torch.core.helpers import read_config, read_from_file
from substeps import *
from helpers import *
print(":: execution started")
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config", help="path to yaml config file")
config_file = parser.parse_args().config
config = read_config(config_file)
metadata = config.get("simulation_metadata")
num_episodes = metadata.get("num_episodes")
num_steps_per_episode = metadata.get("num_steps_per_episode")
visualize = metadata.get("visualize")
registry = Registry()
registry.register(read_from_file, "read_from_file", "initialization")
runner = Runner(config, registry)
runner.init()
print(":: preparing simulation...")
for episode in trange(num_episodes, desc=f":: running episode", ncols=108):
runner.reset()
for step in trange(
num_steps_per_episode,
desc=f":: executing substeps",
leave=False,
ncols=108,
ascii=True,
):
runner.step(1)
print(":: execution completed")