-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 729 Bytes
/
Copy pathmain.py
File metadata and controls
28 lines (23 loc) · 729 Bytes
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
# Author: Bishal Sarang
from solve import Solution, start_config
from state import State
from copy import deepcopy
def main():
# Create Solution Object
s = Solution()
# Start from start configureation
start = start_config
# Calculate level and manhattan distance for start config
g, h = 0, s.calculate_manhattan_distance(start)
# Make root State as start config
root_state = State(g=g, h=h, parent=None, board=deepcopy(start))
# Solve Recursively starting from root state
s.solve(root_state)
# Recolor the nodes and edges to show the path
s.trace_path()
#
s.draw_legend()
# Write State space tree
s.write_image("out.png")
if __name__ == '__main__':
main()