-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mazeworld.py
65 lines (51 loc) · 1.89 KB
/
test_mazeworld.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from MazeworldProblem import MazeworldProblem
from Maze import Maze
#from uninformed_search import bfs_search
from astar_search import astar_search
# null heuristic, useful for testing astar search without heuristic (uniform cost search).
def null_heuristic(state):
return 0
# Test problems
# test_maze2 = Maze("maze2.maz")
# print test_maze2
# test_mp = MazeworldProblem(test_maze2, (2, 2))
# print test_mp.robot1_table
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print result
test_maze3 = Maze("maze3.maz")
print test_maze3
test_mp = MazeworldProblem(test_maze3, (1, 4, 1, 3, 1, 2))
# print(test_mp.get_successors_all(test_mp.start_state))
#this should explore a lot of nodes; it's just uniform-cost search
# result = astar_search(test_mp, null_heuristic)
# print(result)
# this should do a bit better:
result = astar_search(test_mp, test_mp.wavefront_heuristic)
print(result)
# test_mp.animate_path(result.path)
# Your additional tests here:
# test_maze01 = Maze("maze01.maz")
# print test_maze01
# test_mp = MazeworldProblem(test_maze01, (1, 2, 1, 1, 1, 0))
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print(result)
# test_maze02 = Maze("maze02.maz")
# print test_maze02
# test_mp = MazeworldProblem(test_maze02, (4, 0, 1, 0))
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print(result)
# test_maze03 = Maze("maze03.maz")
# print test_maze03
# test_mp = MazeworldProblem(test_maze03, (3, 5, 3, 5, 3, 5))
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print(result)
# test_maze04 = Maze("maze04.maz")
# print test_maze04
# test_mp = MazeworldProblem(test_maze04, (17, 16, 17, 18))
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print(result)
# test_maze05 = Maze("maze05.maz")
# print test_maze05
# test_mp = MazeworldProblem(test_maze05, (31,27))
# result = astar_search(test_mp, test_mp.manhattan_heuristic)
# print(result)