-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_random_agent.py
40 lines (31 loc) · 1.13 KB
/
run_random_agent.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
from argparse import ArgumentParser
from gym.wrappers import TimeLimit
from minetester import Minetest
def main(minetest_path, max_steps, show, seed):
env = Minetest(minetest_executable=minetest_path, seed=seed)
env = TimeLimit(env, max_episode_steps=max_steps)
obs = env.reset()
done = False
while not done:
action = env.action_space.sample()
obs, rew, done, info = env.step(action)
if show:
env.render()
env.close()
if __name__ == "__main__":
parser = ArgumentParser("Run random agent in Minetest environment")
parser.add_argument(
"--minetest-path",
type=str,
default="../minetest/bin/minetest",
help="Path to minetest executable.",
)
parser.add_argument(
"--max-steps", type=int, default=1e6, help="Maximum number of episode steps.",
)
parser.add_argument("--show", action="store_true", help="Render the environment.")
parser.add_argument(
"--seed", type=int, default=0, help="Seed of the environment.",
)
args = parser.parse_args()
main(args.minetest_path, args.max_steps, args.show, args.seed)