-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
44 lines (32 loc) · 1.09 KB
/
run.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
# Search methods
import search
a = "Lowest cost first:"
b = "Heuristic and cost lower sum first:"
ab = search.GPSProblem('A', 'B', search.romania)
oe = search.GPSProblem('O', 'E', search.romania)
so = search.GPSProblem('S', 'O', search.romania)
ln = search.GPSProblem('L', 'N', search.romania)
print("*** Search A -> B ***")
print a
print search.lowest_cost_first_graph_search(ab).path()
print b
print search.heuristic_first_graph_search(ab).path()
print("*** Search O -> E ***")
print a
print search.lowest_cost_first_graph_search(oe).path()
print b
print search.heuristic_first_graph_search(oe).path()
print("*** Search S -> O ***")
print a
print search.lowest_cost_first_graph_search(so).path()
print b
print search.heuristic_first_graph_search(so).path()
print("*** Search L -> N ***")
print a
print search.lowest_cost_first_graph_search(ln).path()
print b
print search.heuristic_first_graph_search(ln).path()
#print search.astar_search(ab).path()
# Result:
# [<Node B>, <Node P>, <Node R>, <Node S>, <Node A>] : 101 + 97 + 80 + 140 = 418
# [<Node B>, <Node F>, <Node S>, <Node A>] : 211 + 99 + 140 = 450