-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (37 loc) · 1.22 KB
/
main.py
File metadata and controls
54 lines (37 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
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 9 10:53:07 2018
@author: iakov
"""
from create_maze_graph import create_maze_graph
import graph_movement
import numpy
from numpy.random import randint as randint
import matplotlib.pyplot as plt
from random import choice
import networkx as nx
def print_maze(maze,coordinates):
plt.figure()
color_map = []
for node in maze.nodes():
if maze.nodes()[node]['position'] == True:
color_map.append('blue')
elif maze.nodes()[node]['goal'] == True:
color_map.append('green')
else:
color_map.append('red')
nx.draw(maze,coordinates, node_color=color_map)
maze, coord_dict, coordinates = create_maze_graph()
starting_node = randint(0,maze.size()+1)
goal_node = randint(0,maze.size()+1)
maze.nodes()[starting_node]['position'] = True
maze.nodes()[goal_node]['goal'] = True
agent = graph_movement.Agent(starting_node,maze.nodes()[starting_node]['coordinates'],coord_dict,goal_node)
print_maze(maze,coordinates)
print(agent.coordinates)
plan =["right","up","right","right","down","right","down"]
agent.execute_plan(plan,maze)
print(agent.coordinates)
print_maze(maze,coordinates)
print(agent.invalid_counter)
#print maze.edges