-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (32 loc) · 1.14 KB
/
Copy pathmain.py
File metadata and controls
45 lines (32 loc) · 1.14 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
import fonctions
import time
import os
from fonctions import *
time_start = time.perf_counter()
history_move = []
terrain = generate_maze()
start, end = start_end(terrain)
while(True):
cellule = scan(start,terrain)
#print(cellule)
backup = backup_scan(cellule)
somme, h_dist, s_min, h_min = check_distance(start, cellule, end)
new_cellule = shortest_distance(cellule, somme, h_dist, s_min, h_min)
if new_cellule in history_move:
cellule.remove(new_cellule)
somme, h_dist, s_min, h_min = check_distance(start, cellule, end)
new_cellule = shortest_distance(cellule, somme, h_dist, s_min, h_min)
terrain[new_cellule[1]][new_cellule[0]] = "◊"
history_move.append(new_cellule)
start = new_cellule
time.sleep(0.6)
clear = lambda: os.system('cls') #on Windows System
clear()
if new_cellule == end:
break
print_maze(terrain)
print_maze(terrain)
time_end = time.perf_counter() #calculate the time of execution
print("execution time : {} secondes".format(round(time_end - time_start,6)))
print("Algorithme solve the problem in {} moves".format(len(history_move)))
input("Press enter to exit !")