Giter Club home page Giter Club logo

n_puzzle_42's Introduction

Python 3.7 Build Status

N-puzzle

N-puzzle is a project as part of the 42 algorithmic curriculum. The aim of the project is to build an algorithm which solves whichever npuzzle is given as input (The most common npuzzles are 8-puzzle of size 3 x 3 and 15-puzzle of size 4 x 4). The npuzzle has to be solvable otherwise the program will tell the user the npuzzle provided cannot be solved.

The npuzzle game consists of a matrix with 8 filled tiles and 1 blank area. A few or all the filled tiles can be misplaced. The goal is to obtain the final sorted npuzzle by swapping a tile with the blank area.

Unlike the most common version of the n-puzzle game, the aimed puzzle of this project forms a snail around the center, as represented below:

starting 8-puzzle goal 8-puzzle
starting 8-puzzle ending 8-puzzle

Usage


python3 n_puzzle.py [-h] [-d] [-a astar|ida_star|uniform|greedy] [-m manhattan|linear_conflict|misplaced_tiles] [-g n] -f puzzle_file [-v]

Arguments :

Short flag Long flag Description
-h --help Show help message
-d --detail Outputs detailed path chosen by the algorithm
-f FILENAME --filename FILENAME Gives a text file containing a puzzle to solve
-g INT --generator INT Generates a solvable puzzle of size {int}
-m METHOD --method METHOD Method to be used for heuristic calculation. Default is misplaced_tiles
-a ALGO --algo ALGO Algorithm used to solve the n-puzzle. Default is uniformed_cost
-v --visu Show the results as a GUI

Example


solution first steps

solution last steps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.