55 lines
964 B
Plaintext
55 lines
964 B
Plaintext
class: "GraphSearchTest"
|
|
algorithm: "aStarSearch"
|
|
|
|
diagram: """
|
|
2 3 2
|
|
S --- A --- C ---> G
|
|
| \ / ^
|
|
3 | \ 5 / 1 /
|
|
| \ / /
|
|
B --- D -------/
|
|
4 5
|
|
|
|
S is the start state, G is the goal. Arrows mark possible state
|
|
transitions. The number next to the arrow is the cost of that transition.
|
|
|
|
The heuristic value of each state is:
|
|
S 6.0
|
|
A 2.5
|
|
B 5.25
|
|
C 1.125
|
|
D 1.0625
|
|
G 0
|
|
"""
|
|
# The following section specifies the search problem and the solution.
|
|
# The graph is specified by first the set of start states, followed by
|
|
# the set of goal states, and lastly by the state transitions which are
|
|
# of the form:
|
|
# <start state> <actions> <end state> <cost>
|
|
graph: """
|
|
start_state: S
|
|
goal_states: G
|
|
S 0 A 2.0
|
|
S 1 B 3.0
|
|
S 2 D 5.0
|
|
A 0 C 3.0
|
|
A 1 S 2.0
|
|
B 0 D 4.0
|
|
B 1 S 3.0
|
|
C 0 A 3.0
|
|
C 1 D 1.0
|
|
C 2 G 2.0
|
|
D 0 B 4.0
|
|
D 1 C 1.0
|
|
D 2 G 5.0
|
|
D 3 S 5.0
|
|
"""
|
|
heuristic: """
|
|
S 6.0
|
|
A 2.5
|
|
B 5.25
|
|
C 1.125
|
|
D 1.0625
|
|
G 0
|
|
"""
|