-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_maze.py
More file actions
45 lines (34 loc) · 1.22 KB
/
run_maze.py
File metadata and controls
45 lines (34 loc) · 1.22 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
44
45
# run_maze.py
import time
from environment.base_env import BaseMazeEnv
from environment.env_renderer import EnvRenderer
import pygame
import sys
# This is for testing porpose
def main():
# Create Environment
env = BaseMazeEnv(width=20, height=20, num_keys=3,num_obstacles=0,peek_distance=2,distance_type="manhattan")
obs = env.reset()
env_renderer = EnvRenderer(maze_env=env,cell_size=30,fps=30)
done = False
while not done:
env_renderer.render()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Sample a random action
action = env.sample_action()
print(f"Action: {action}")
obs, reward, done, _ = env_renderer.step(action)
# agent_pos,agent_view,goal_distance,keys_distances,obstacle_distances = obs
#
# print(f"Agent pos: {agent_pos}")
# print(f"Agent view:\n {agent_view}")
# print(f"Goal distance: {goal_distance}")
# print(f"Keys distances: {keys_distances}")
# print(f"Obstacle distances: {obstacle_distances}")
# print(f"Reward: {reward}, Done: {done}")
env.close()
if __name__ == "__main__":
main()