Coder Social home page Coder Social logo

asarandi / n-puzzle Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 6.0 1002 KB

My n-puzzle solver: A* and IDA* search, heuristics, different puzzle configurations and sizes

Home Page: https://projects.intra.42.fr/projects/n-puzzle

Python 61.61% Shell 3.31% Roff 1.03% Makefile 0.91% C 33.14%
n-puzzle a-star heuristic-search-algorithms 15-puzzle linear-conflict ida-star-algorithm heuristics 42fremont 42siliconvalley

n-puzzle's Introduction

n-puzzle @ 42 fremont

usage: solver.py [-h] [-c] [-ida] [-g] [-u]
                 [-f {hamming,gaschnig,manhattan,conflicts}]
                 [-s {zero_first,zero_last,snail}] [-p] [-v]
                 file

n-puzzle @ 42 fremont

positional arguments:
  file                  input file

optional arguments:
  -h, --help            show this help message and exit
  -c                    colors
  -ida                  ida* search
  -g                    greedy search
  -u                    uniform-cost search
  -f {hamming,gaschnig,manhattan,conflicts}
                        heuristic function
  -s {zero_first,zero_last,snail}
                        solved state
  -p                    pretty print solution steps
  -v                    gui visualizer

search:

default search is A*

  • fast and efficient
  • memory heavy

or use -ida for IDA*

  • light on memory
  • slower than a*

input puzzle configurations:

-s zero_first (blank tile first)

4
00 01 02 03
04 05 06 07
08 09 10 11
12 13 14 15

-s zero_last (blank tile last)

4
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 00

-s snail (default, spiral pattern)

4
01 02 03 04
12 13 14 05
11 00 15 06
10 09 08 07

heuristics:

-f hamming hamming distance aka "tiles out of place"

-f gaschnig performs better than hamming distance

-f manhattan manhattan distance heuristic (default)

-f conflicts linear conflicts usually more informed than manhattan distance

miscellaneous:

-g greedy search: ignores the g(n) in A* formula f(n) = g(n) + h(n), quickly finds a suboptimal solution

-u uniform cost search: discards the h(n) in A* formula (turns off heuristics and becomes dijkstra's, slow)

-c colors in terminal output

-p pretty print solution steps

-v replay solution steps in graphical visualizer

resources/screenshot.png

n-puzzle's People

Contributors

asarandi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

n-puzzle's Issues

game 49

Hello sir, @asarandi
I would like to engage(hire) you to create a simple script application for me.
Basically there is this online hobby game I do play online
49 game ( https://logigames.bet9ja.com/Games/Launcher?gameId=11000&provider=0&sid=&pff=1&skin=201 )
Where one choose from 49 numbers 6 accurate numbers that will display at the end of game session
Note: the script or application can be online real time or hosted online I will pay for the monthly hosting fees & maintenance
start up budject : $3k
i await your reply @asarandi
thanks

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.