Skip to content

This Repository contains a solver for fifteen-puzzle To be specific, the NxN sliding puzzle solver in JAVA. The program uses a specific version of Kruskal Algorithm mainly known by A* algorithm with three different heuristics. It uses greedy version of the A* algorithm along side of different heuristics in order to achieve faster solutions

Notifications You must be signed in to change notification settings

peyz21/N-PuzzleSolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FifteenPuzzleSolver (N-Puzzle Solver)

This Repository contains an experimental solver for fifteen-puzzle To be specific, the NxN sliding puzzle solver in JAVA written by my Partenr and Myself. The program uses a specific version of Kruskal Algorithm mainly known by A* algorithm with 3 different heuristics to obtain the result. It uses Greedy version of the A* algorithm ( also known as Pure-Heurisitc) along side of different a combination of heuristics in order to achieve a realtively fast solution for a given board (aproxiamtely less than 30 seconds). The solver then produce a solution direction in a given format for each given board.

Note 1: This program does not focus on the optimality rather it focuses on more cases solved.

Note 2: The solution generated will have the form : (BoardPiece - Direction) it will not directly solve but rather finds a solution for the given board.

Example board1Soution.txt:

image

Note 3: The application reads the boards from the "testcases" folder and writes the solution in the given boardName inside the "solutions" folder.

Note 4: I included 10 different test cases with various boars sizes less than 9x9, which will work optimally but feel free to add more under the "./testcases" but be sure to follow the given format for the boards. (board size on the first line, then the board with the position for zero empty)

image

Be aware that the bigger the board size gets, the longer this solution will take. ( best wroks within the range of 3-7)

Note 5: the SDK/JDK is set to oracle LTS 17.0.5 but feel free to try it with newer or older JAVA versions.

image

Step 1: After downloading, Move to the src/fifteenpuzzle/Solver.java image

Step 2: Scroll down to the main() method on line 420.

Step 3: You can follow 1 of the 2 options in order to produce the board result (3.1 or 3.2):

-3.1: Geneartion of the solution by passing parameters to the main while running through IDE: The main method takes 1 variable an array of strings, more specifically of size 2 file names: "Board Name", "Solution Board Name" and their relative path. follow the TYPE 1, which is uncommenting the lines 433-435 and commenting the lines 439-441, then in your IDE give the main() following parameters:

image

then save and run the application.

-3.2: Manually editing the code: Follow the TYPE 2, by changing the name and path of the board name in "Input" decleration and the solution board name in the "FileName" decleration:

image

then save and run the application.

  • Reflections and resutls for the following project/application are written in the pdf file below:

https://drive.google.com/file/d/1UrZMYWc7-BuABHP-wrg22Ixtask7Cqa-/view?usp=sharing

About

This Repository contains a solver for fifteen-puzzle To be specific, the NxN sliding puzzle solver in JAVA. The program uses a specific version of Kruskal Algorithm mainly known by A* algorithm with three different heuristics. It uses greedy version of the A* algorithm along side of different heuristics in order to achieve faster solutions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages