An open API service indexing awesome lists of open source software.

https://github.com/av1m/sliding-block-puzzles

Sliding block/tile puzzle solver using multiple algorithms 🧩
https://github.com/av1m/sliding-block-puzzles

algorithms artificial-intelligence sliding-puzzle-game

Last synced: 5 months ago
JSON representation

Sliding block/tile puzzle solver using multiple algorithms 🧩

Awesome Lists containing this project

README

          

# Sliding block puzzles

[![Sliding Puzzle CI](https://github.com/av1m/sliding-block-puzzles/actions/workflows/actions.yaml/badge.svg)](https://github.com/av1m/sliding-block-puzzles/actions/workflows/actions.yaml)
[![Python3.9](https://img.shields.io/badge/Python-3.9-blue)](https://docs.python.org/3/whatsnew/3.9.html)
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/av1m/sliding-block-puzzles/blob/master/LICENSE)
[![Try demo](https://img.shields.io/badge/demo%20%F0%9F%8E%AE-red)](https://av1m.github.io/slide_puzzle/#/)

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()](sliding_puzzle/representation/puzzle.py) function

> 💡 An experimental protocol was carried out. The source code as well as an analysis is available in the [report](report/) directory

## Usage 📖

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

1. In a python script, consult the [sample](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

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

More complex

```shell
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](https://github.com/av1m/slide_puzzle)

## Get started 🎉

Install the dependencies

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

You have now added the dependency, you can:

* Run an example

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

> 💡 All the examples are in the [`sample/`](./sample/) directory

* Run the CLI

```shell
sliding_puzzle
# Or, call it with python
python -m sliding_puzzle
```

* Run the server

```shell
cd sliding_puzzle
make serve
```

## Developers 👨‍💻

Use `python3` or `python` command (depending on your configuration)

1. Clone this project

```shell
git clone https://github.com/av1m/sliding-block-puzzles
cd src-puzzles
```

2. Run make command

```shell
make install
```

3. Test the project

```shell
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 :

```bash
gunicorn sliding_puzzle.wsgi --reload --timeout 1000
```

For example, if you want to deploy to [Heroku](https://heroku.com), you can create a Heroku project. Then, add the
heroku project to this project (through `git remote add` ) and run this command

```shell
make deploy
```

> In order to deploy to Heroku, you need a [`Procfile` file](https://devcenter.heroku.com/articles/getting-started-with-python#define-a-procfile)