Skip to content

m1lhaus/Python-15-puzzle-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING: Not fully tested and no check for solvability!


Python '15' puzzle solver

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).

'15' solver visualization

Main features

  • 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

Usage:

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])
  
  ...

Requirments

License:

GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

About

Python script based on A* algorithm to find solution of '15' puzzle game. Final solution (moves) is being visualized by PyQt.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages