TheFebrin / AI-sokoban-solver-bot

AI agent solves Sokoban puzzle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sokoban-AI-solver

Agent that solves Sokoban puzzle.

Table of contents

General info

Bot that was made to solve Sokoban puzzles on this website.
An example puzzlehere.

Screenshots

Screenshot

Libraries

  • sys
  • numpy
  • keyboard
  • Image
  • os

How does it work?

  1. Downloads the map canvas and changes it to B&W.
  2. Maps pixels to txt characters.
  3. Maps every k x k block tile to single character.
  4. Now BFS based algorithm can use this .txt map to find a way to solve the puzzle!

How to use it?

First you need to download the map.
You can use this script, (it's also included in project files get_canvas.js).
I use https://tampermonkey.net/ to make it faster.
Type it in Web inspector console.

const result = document.querySelectorAll("canvas")
const dataUrl = result[0].toDataURL('image/png').replace("image/png", "image/octet-stream");
window.location.href = dataUrl;

After that you need to install all required libraries in Solve.py
Run sudo python Solve.py to start the program.

TODO

Better blocks mapping, because now it works only when blocks are 64 x 64.
Another BFS based algorithm or A* running as parallel thread.
Maybe do all with only one script.

About

AI agent solves Sokoban puzzle.


Languages

Language:Python 96.6%Language:JavaScript 3.4%