Coder Social home page Coder Social logo

quangmnh / sokoban-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 17.47 MB

Introduction to AI assignment 1 HCM University of Technology, term 211

Python 100.00%
sokoban sokoban-solver sokoban-game bfs astar-algorithm astar pygame among-us hcmut assignment

sokoban-bot's Introduction

Sokoban Bot

Introduction to AI assignment 1 HCM University of Technology, term 211

Abstract

This is basically a solver for Sokoban game using Breadth-first Search and A* algorithm to search state space for a solution. Example level sets are taken from ksokoban.online, "Mini Cosmos" and "Micro Cosmos" (40 levels each)

Algorithm

(see more in the Sokoban.py code, where I explain the algorithm in details)

  • Breadth-first Search: We keep generating new state that is a combination of main character's and crates' co-ordinations push it to the queue. Pop it every loop and proceed to generate more state till solution.

  • A*: Just like above but with a heuristic, the new state is tagged with a cost function to switch to a better branch when possible.

  • In both function, I use a heuristic for more feasible searching, which is the dead lock detection. So actually, the BFS is not a genuine Blind Search, but we will consider it to be a close one. (For real, blind search took so long that I nearly lose my mind waiting)

Instruction

  • import Sokoban class from Sokoban.py and call one of the run functions:

Example:

  from Sokoban import Sokoban
  
  sokoban = Sokoban()

  sokoban.run_all() #run everything, mini, micro, 80 level, both methods
  sokoban.run_all_micro() #run all micro cosmos level (40) with both methods
  sokoban.run_all_mini() #run all mini cosmos level (40) with both methods
  sokoban.run_all_bfs() #run all level (80) with BFS
  sokoban.run_all_astar() #run all level (80) with A*
  sokoban.run_one('astar','micro',1) #run Micro cosmos 1 with A*
  sokoban.run_one('bfs','mini',3) #run Mini cosmos 3 with BFS
  • Or run the game.exe: (see more instruction on the slide)
  • Or run the game.py:
  python game.py

sokoban-bot's People

Contributors

quangmnh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.