forked from ArnaudFickinger/gym-multigrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_env.py
44 lines (31 loc) · 979 Bytes
/
test_env.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
import gym
import time
from gym.envs.registration import register
import argparse
parser = argparse.ArgumentParser(description=None)
parser.add_argument("-e", "--env", default="soccer", type=str)
args = parser.parse_args()
def main():
if args.env == "soccer":
register(
id="multigrid-soccer-v0",
entry_point="gym_multigrid.envs:SoccerGame4HEnv10x15N2",
)
env = gym.make("multigrid-soccer-v0")
else:
register(
id="multigrid-collect-v0",
entry_point="gym_multigrid.envs:CollectGame4HEnv10x10N2",
)
env = gym.make("multigrid-collect-v0")
_ = env.reset()
nb_agents = len(env.agents)
while True:
env.render(render_mode="human", highlight=True)
time.sleep(0.1)
ac = [env.action_space.sample() for _ in range(nb_agents)]
obs, _, done, _ = env.step(ac)
if done:
break
if __name__ == "__main__":
main()