Python script based on A* algorithm to find solution of '15' puzzle game. Final solution (sequence of movements) is being visualized by PyQt. Whole script is works both on Windows and Linux (and maybe on Mac).
- solver script is pure Python 2.7, visualization is written in PyQt4
- algorithm can be simply modified to solve other puzzle dimensions (3x3, 5x5, etc.)
- algorithm uses associative arrays to speed up OPENED, CLOSED set searching
Edit the main part in solver.py!
if __name__ == "__main__":
# ---- SELECT only one heuristic function ------
# calc_hfunc = calc_hfunc_positions
calc_hfunc = calc_hfunc_manhattan
# calc_hfunc = calc_hfunc_none
# -------------------------------------------
init_array = ([SPACER, 2, 3, 4], [6, 5, 10, 12], [9, 1, 8, 15], [13, 14, 7, 11])
target_data = ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, SPACER])
...
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991