-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.py
48 lines (40 loc) · 1.03 KB
/
main.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
45
46
47
48
from time import time
from BFS_search import breadth_first_search
from Astar_search import Astar_search
from RBFS_search import recursive_best_first_search
from puzzle import Puzzle
state=[[1, 3, 4,
8, 6, 2,
7, 0, 5],
[2, 8, 1,
0, 4, 3,
7, 6, 5],
[2, 8, 1,
4, 6, 3,
0, 7, 5]]
for i in range(0,3):
Puzzle.num_of_instances=0
t0=time()
bfs=breadth_first_search(state[i])
t1=time()-t0
print('BFS:', bfs)
print('space:',Puzzle.num_of_instances)
print('time:',t1)
print()
Puzzle.num_of_instances = 0
t0 = time()
astar = Astar_search(state[i])
t1 = time() - t0
print('A*:',astar)
print('space:', Puzzle.num_of_instances)
print('time:', t1)
print()
Puzzle.num_of_instances = 0
t0 = time()
RBFS = recursive_best_first_search(state[i])
t1 = time() - t0
print('RBFS:',RBFS)
print('space:', Puzzle.num_of_instances)
print('time:', t1)
print()
print('------------------------------------------')