Skip to content

liukaren/slider-puzzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

15-Puzzle Solver

Inspired by and modeled after the 8-puzzle assignment from the (free!) Princeton Algorithms Coursera course. This is an exercise in implementing the concepts, and adding some goofy backgrounds. :)

A 3x3 or 4x4 slider puzzle can be shuffled and solved. The solver can be paused any time by hitting "Stop" during playback. You can also just play the game normally.

The solver uses the A* algorithm to explore possible moves. It uses manhattan distance plus linear conflicts to prioritize moves. Note this implementation is not efficient enough for 5x5 boards.

The shuffler uses the Fisher-Yates shuffle to permute the tiles, then checks whether the board is solvable by counting the number of inversions (using mergesort). If the generated board is not solvable, it swaps two adjacent non-zero tiles to place it in the solvable equivalence class.

Attribution

Development

Production

  • yarn run build
  • yarn run deploy

About

15-puzzle solver algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published