Skip to content

Solving Sokoban game using Artificial Intelligence using State space search

License

Notifications You must be signed in to change notification settings

hikariakio/sokoban-python-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sokoban Game AI

Solving Sokoban game using Artificial Intelligence using State space search

About The Project

This was a university assignment to implement the weighted version of classic sokoban game and solve the game in the least amount of moves.

GUI feature is provided by the assignment. The main task is to implement 'mySokobanSolver.py'.

Variant

This variant of Sokoban takes account of the weight of boxes in addition to move cost. The goal of the puzzle is to find the least cost to find the goal state.

Installation

Clone the repo.

   git clone https://github.com/hikariakio/sokoban-python-ai
   cd sokoban-python-ai

Start GUI-mode.

    python gui_sokoban.py

Play On Repl

Play Here!

Usage

How to play

  • Before playing a game, loading a warehouse is required. From the menu bar,
 File > Load warehouse > choose any desired map.
  • Then use arrow keys to move the player.

  • Player can only push a box at a time.

  • The game will over when all boxes are in target locations.

  • 'r' key can be pressed anytime to reset the whole puzzle.

AI Play

AI can help you to solve the puzzle at any point. From the menu bar,

Solve > Plan action sequence

AI will generate the solution based on the current game state. More information can be found in terminal. You can manually play the solution by yourself or you can order AI to play.

Solve > Play action sequence

AI calculation duration depends on the size of map and number of boxes. If there is no valid solution,error message will be shown on terminal.

Screenshots

initial-state terminal1

Warehouse Map

Symbol State
# Tree
$ Box
. Target
@ Player
! Player on Target
* Box on Target

Warehouse map of the above puzzle.

  ####
 ###  ####
 #     $ #
 # #  #$ #
 # . .#@ #
 #########

Weight Variants

AI will try reduce the cost as much as it can when pushing weighted boxes.

  • Normal

initial-state

  • Weighted

initial-state

Box with weight 99 will be prioritized to the nearest target.

License

Distributed under the MIT License.

Acknowledgement

  • Icon images from Risto Stevcev
  • Scaffold Template from QUT IFN680 Assignment1

About

Solving Sokoban game using Artificial Intelligence using State space search

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages