Skip to content

Solves a N-Dimension Puzzle with one of the 4 different path algorithms : Breadth 1st Search, Depth 1st Search, Best 1st Search and A* Search.

License

Notifications You must be signed in to change notification settings

xariskarv/NPuzzle-Solver-AI-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPuzzle-Solver-AI-Algorithms

Purpose

This project was created in order to solve any N-Dimensional NPuzzle game.

Implemented Algorithms

Generator

The generator.c is a program written by @Ioannis Refanidis and its purpose is to generate random NPuzzle problems and save them to .txt files.

How to use the generator

compile:

  gcc generator.c -o generator

Install GCC: https://dev.to/gamegods3/how-to-install-gcc-in-windows-10-the-easier-way-422j

If the executable file is called generator.exe run:

  generator.exe <filname> <id1> <id2> 

where

  <filaneme>: the prefix of the file
  <id1> <id2>: 2 numbers for the suffix of the file

e.g.

   generator.exe puzzles 11 20

Will create 10 files with names: puzzles11.txt....puzzles20.txt

Example of a puzzles file

   4  5  0 
   1  3  2
   6  8  7

How to run Java Main

   javac Main.java

then run:

   javac Main <method> <input.txt> <solution.txt>

where:

    <method>: The algorithm used to solve the puzzle
    <input.txt>: The file with the puzzle
    <output.txt>: The file for the solution

e.g.

    java Main astar puzzles3.txt solution

Example of an output file

    Search algorithm: A* Search 
    Number of steps to achieve solution: 200
    Execution time: 0.027 seconds 

    1  2  3
    4  5  6
    7  8  0

    Height: 17

Results

The execution time shows the time that the algorithm needed to find the solution.
The number of steps show how many nodes did the algorithm visit in order to find the solution.
The height shows the solution node's height.

About

Solves a N-Dimension Puzzle with one of the 4 different path algorithms : Breadth 1st Search, Depth 1st Search, Best 1st Search and A* Search.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages