av1m / sliding-block-puzzles

Sliding block/tile puzzle solver using multiple algorithms 🧩

Home Page:https://av1m.github.io/slide_puzzle/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sliding block puzzles

Sliding Puzzle CI Python3.9 MIT License Try demo

Representation of a slide puzzle and implementation of algorithms allowing the resolution In this repository you will find:

  • Command Line Interface (CLI)
  • Webservice written in Flask (WSGI Server)
  • Representation of a Puzzle (i.e. sliding block puzzle)
  • Heuristics
    • Linear Conflicts
    • Misplaced
    • Manhattan
  • Algorithms
    • A* Search
    • Breadth-First Search
    • Depth-First Search
    • Depth-Limited Search
    • Greedy Best-First Search
    • Iterative Deepening Depth-First Search
    • Uniform-Cost Search
    • Bidirectional search
    • Iterative Lengthening Search
    • Iterative Deepening A* Search

⚠️ Because it's a university project, the cost is not real but can be modified in the Puzzle:get_cost() function

πŸ’‘ An experimental protocol was carried out. The source code as well as an analysis is available in the report directory

Usage πŸ“–

At this stage, you can use the project in different ways:

  1. In a python script, consult the sample directory for an example

  2. Run the CLI with the command python -m sliding_puzzle(maybe you need to make source .venv/bin/activate) Simple command

    python3 -m sliding_puzzle --tiles 1 3 2 4 0 7 5 8 6 --method a_star

    More complex

    python3 -m sliding_puzzle \
      --verbose \
      --tiles 4 1 2 3 5 6 7 11 8 9 10 15 12 13 14 0 \
      --method a_star depth_limited \
      --no-blank-at-first
  3. Run the server with the command ```make serve

  4. Run a client GUI that request the server (created at 3.) or directly in Python (Flask, Django ...). Try an example writing in Flutter

Get started πŸŽ‰

Install the dependencies

python -m pip install git+https://github.com/av1m/sliding-block-puzzles

You have now added the dependency, you can:

  • Run an example

    wget -qO- https://raw.githubusercontent.com/av1m/sliding-block-puzzles/master/sample/simple.py | python -

    πŸ’‘ All the examples are in the sample/ directory

  • Run the CLI

    sliding_puzzle
    # Or, call it with python
    python -m sliding_puzzle
  • Run the server

    cd sliding_puzzle
    make serve

Developers πŸ‘¨β€πŸ’»

Use python3 or python command (depending on your configuration)

  1. Clone this project

    git clone https://github.com/av1m/sliding-block-puzzles
    cd src-puzzles
  2. Run make command

    make install
  3. Test the project

    make test

Everything has been installed and configured correctly! 🎊

Deploy the server πŸš€

We use a WSGI server.

It can easily be run and deployed using the command :

gunicorn sliding_puzzle.wsgi --reload --timeout 1000

For example, if you want to deploy to Heroku, you can create a Heroku project. Then, add the heroku project to this project (through git remote add ) and run this command

make deploy

In order to deploy to Heroku, you need a Procfile file

About

Sliding block/tile puzzle solver using multiple algorithms 🧩

https://av1m.github.io/slide_puzzle/#/

License:MIT License


Languages

Language:Python 98.7%Language:Makefile 1.3%Language:Procfile 0.1%