{"id":23897689,"url":"https://github.com/omerkel/sokoban","last_synced_at":"2025-06-22T21:37:58.342Z","repository":{"id":71262960,"uuid":"192981869","full_name":"OMerkel/Sokoban","owner":"OMerkel","description":"倉庫番 - Sokoban solitaire puzzle game","archived":false,"fork":false,"pushed_at":"2023-07-13T12:20:10.000Z","size":2526,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T17:19:14.266Z","etag":null,"topics":["entertainment","games","puzzle","puzzle-game","single-player","single-player-game","solitaire","solitaire-game"],"latest_commit_sha":null,"homepage":"https://omerkel.github.io/Sokoban/html5/src","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OMerkel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-20T20:14:09.000Z","updated_at":"2024-01-12T21:27:53.000Z","dependencies_parsed_at":"2025-04-12T05:15:33.983Z","dependency_job_id":null,"html_url":"https://github.com/OMerkel/Sokoban","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/OMerkel/Sokoban","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OMerkel%2FSokoban","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OMerkel%2FSokoban/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OMerkel%2FSokoban/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OMerkel%2FSokoban/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OMerkel","download_url":"https://codeload.github.com/OMerkel/Sokoban/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OMerkel%2FSokoban/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261373719,"owners_count":23148919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["entertainment","games","puzzle","puzzle-game","single-player","single-player-game","solitaire","solitaire-game"],"created_at":"2025-01-04T17:17:13.768Z","updated_at":"2025-06-22T21:37:53.323Z","avatar_url":"https://github.com/OMerkel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"Sokoban icon\" width=\"64\" src=\"html5/src/img/icons/sokoban64.png\" /\u003e Sokoban\n=============================================\n\n倉庫番 - Sokoban solitaire logic puzzle game\n\nThe term _Sokoban_ means _warehouse keeper_. The player controls a warehouse keeper.\nHe has to push boxes onto marked storage locations to solve each level.\n\nThe original game of Sokoban was created back in the early 1980s Home Computer era by\nHiroyuki Imabayashi then distributed by Thinking Rabbit, a Japanese software house.\n\n## Android APK available for install\n\n\u003cimg alt=\"Android APK available\" src=\"res/android.gif\" width=\"32\" /\u003e https://github.com/OMerkel/Sokoban/releases\n\n## Usage of Browser Javascript Version\n\nSimply start a session of the [Sokoban game](https://omerkel.github.io/Sokoban/html5/src)\nin your browser window. \n\n## Usage of Dart Version\n\nYou can find a version written in Dart programming language in this repository, too.\nThis is a ASCII graphics version played on the command line console (STDIN/STDOUT).\nA Dart SDK is needed to run it ( https://dart.dev ).\n\n```\n$ dart --version\nDart VM version: 2.4.0 (Unknown timestamp) on \"linux_x64\"\n$ cd dart\n$ dart sokoban.dart ../3rdParty/Levels/Microban.txt 3\nFound 155 levels in Microban.txt.\nLevel 3:\n  ####\n###  ####\n#     $ #\n# #  #$ #\n# . .#@ #\n#########\n```\n\nWhat the symbols represent in the level files and on screen while playing the game:\n\n```Dart\nvar symbol = {\n  'floor':            \" \",\n  'wall':             \"#\",\n  'box':              \"\\$\",\n  'sokoban':          \"@\",\n  'storage':          \".\",\n  'boxOnStorage':     \"*\",\n  'sokobanOnStorage': \"+\"\n};\n```\n\nUse the following keys to control the Sokoban\n\n```Dart\nvar key = {\n  'left':  'h',\n  'down':  'j',\n  'up':    'k',\n  'right': 'l'\n};\n```\n\n__Ctrl+D__ exits the current game\n\n## Solving Sokoban Levels\n\n```\n$ python --version\nPython 3.5.2\n$ cd python\n$ python sokoban_solver_1.py 0\n###\n#.#\n# #\n#$#\n#@#\n###\nPush box onto storage!\nUU\n0.000347137451171875 seconds\n```\n\nThe selected level or challenge indexed by '0' on the command line is shown with following symbols.\n\n```python\nlevels = {\n  'symbol' : {\n    'floor':            \" \",\n    'wall':             \"#\",\n    'box':              \"$\",\n    'sokoban':          \"@\",\n    'storage':          \".\",\n    'boxOnStorage':     \"*\",\n    'sokobanOnStorage': \"+\",\n  },\n...\n```\n\nThe solution found is shown below this output of the challenge.\n\n```python\n  orientation = {\n    'down':  { 'move': 'd', 'push': 'D', 'dx':  0, 'dy':  1 },\n    'left':  { 'move': 'l', 'push': 'L', 'dx': -1, 'dy':  0 },\n    'up':    { 'move': 'u', 'push': 'U', 'dx':  0, 'dy': -1 },\n    'right': { 'move': 'r', 'push': 'R', 'dx':  1, 'dy':  0 }\n  }\n```\n\nThe two uppercase 'UU' in the output indicate that two pushes have to be performed to solve the challenge.\n\n__sokoban_solver_1.py__ works for simple levels in very low time.\n\nSolving challenge 3 by UUluRR and 5 using the moves and pushes llDurrdL:\n\n```\n$ python sokoban_solver_1.py 3\n######\n#   .#\n#  ###\n##$#\n #@#\n ###\nAround the corner.\nUUluRR\n0.003311634063720703 seconds\n$ python sokoban_solver_1.py 5\n#####\n#  @#\n#*$ #\n#.###\n###\nEasy going!\nllDurrdL\n0.016065359115600586 seconds\n```\n\nAs soon as the warehouse keeper gets more liberties or freedom to move the time to solve the challenges\nincreases enormously. This is since the _brute-force-attack_ to find the solution traverses situations\nover and over again even if the same situation has been _visited_ and thus has been analysed before.\nMost likely then the computer runs _out of memory_ or you get a _memory error_ or _couldn't allocate_\nmore memory after a while.\n\n```\n$ python sokoban_solver_1.py 4\n  ######\n  #.   #\n### ##$###\n#@ $   . #\n#    ####*\n######\n```\n\nTime to wait or give up...\n\n__sokoban_solver_2.py__ avoids traversing already visited situations while searching for the solution.\nThis is done by storing each level situation in a set named _visited_ in the python code.\n\n```\n$ python sokoban_solver_2.py 4\n  ######\n  #.   #\n### ##$###\n#@ $   . #\n#    ####*\n######\n\ndrrruLuurrrDullldddlluRdrUUdrrR\n0.09712076187133789 seconds\n$ python sokoban_solver_2.py 6\n#######\n#.@ # #\n#$* $ #\n#   $ #\n# ..  #\n#  *  #\n#######\nNot so easy...\nDDrdrruLruLLDllU\n3.3833835124969482 seconds\n$ python sokoban_solver_2.py 7\n #####\n##   #\n#@$  #\n#. $##\n#.  #\n#####\nOn the other side\nRurrdLulDlddrrULuurrdLulDDrdL\n0.0918741226196289 seconds\n```\n\nStill the Sokoban solver has limitations to find solutions for levels like the following one.\n\n```\n$ python sokoban_solver_2.py 8\n    #####\n    #   #\n    #$  #\n  ###  $###\n  #  $  $ #\n### # # # #*#####\n#   # ### ##  ..#\n# $  $      @ ..#\n##### #### #  ..#\n    #      *#####\n    ########\nModerate challenge\n```\n\nAgain memory consumption is high. And it continues to search for solutions even if it is\nclear that a specific solution is already unsolveable. E.g. if a box gets pushed into\na corner and can not be pushed out of the corner anymore. Like this:\n\n```\n    #####\n    #$  #\n    #   #\n...\n```\n\nA box gets immovable as soon as it gets pushed into a corner of walls or even other boxes.\nSuch corners look like this\n\n```\n\n   #$\n@$  $\n\n```\n\nIf the Sokoban pushes the box twice right (RR) into the corner shape then none of the boxes\nare moveable any longer.\n\n```\n##########\n#        #\n# @  *$  #\n#.   #$  #\n#.       #\n##########\n```\n\nAs another example the warehouse keeper can not move any box in this situation.\nThe situation is unsovable. Meaning the strategy to optimize the search finding a\nsolution is to avoid pushes of a box into such corner shapes as long as the compacted\nshape is not part of the intended solution.\n\nFurthermore to reduce memory consumption of the remaining search tree instead of\nstoring the whole level scenario it is sufficient to store a much shorter unique\nidentifier of the level scenario. This is usually done by storing so called hash\nvalues representing the data. Mind that you have to avoid hash value collisions.\nPython is helping here at this point since some data representations are already\nstored using hash values. So it is not needed to implement a hash function. Instead\nthe python internal hash function of the data is used. Since lists do not own a hash\nvalue but strings the list is joined as a string:\n\n```Python\n    visited = set([hash(''.join(self.getLevel()))])\n    ...\n          sHash = hash(''.join(s.getLevel()))\n          if sHash not in visited:\n            ...\n            visited.add(sHash)    \n```\n\nAlthough __sokoban_solver_3.py__ will allow to render a solution for a greater\nset of levels the runtime is still considered being high on nowadays machines.\n\n```\n$ python sokoban_solver_3.py 8\n    #####\n    #   #\n    #$  #\n  ###  $###\n  #  $  $ #\n### # # # #*#####\n#   # ### ##  ..#\n# $  $      @ ..#\n##### #### #  ..#\n    #      *#####\n    ########\nModerate challenge\nllluuuLLUllDlldddrRRRRRRRRdrUllllllllllulldRRRRRRRRRRRuRRlDlllluuullulldDDuulldd\ndrRRRRRRRRdRRlUlllluuullLulDDDuulldddrRRRRRRRRuRDlllluuullluuurDDluulDDDDDuulldd\ndrRRRRRRRRRRllllluuulLLulDDDuulldddrRRRRRRRRRldR\n5176.865227937698 seconds\n$ python sokoban_solver_3.py 9\n*####        ####*\n##  ##########  ##\n#                #\n#  *###########  #\n## #*  #  #   # ##\n # #      #   # #\n # #  ##$ #  ## #\n # ## #  $#$ #  #\n # *# #      ## #\n # ## #  ##   # ##\n##*#  #########  #\n# .#             #\n#@..#  #######  ##\n*#######     ####*\nA long way...\nurUUUUUUUUluRRRRRRRRRRRRRurDDDDDDDDDrdLLLLLLLLLLdlUUUUUUluRRRRDrDuluurDDlDlddrUU\nUruLdddRRRdrUUUlDuuurrdLulDDrddLLLUluuLLulDDDDDDldRRRRRRRRRRdrUUUUUUUUUruLLLLLLL\nLLLLLLulDDDDDDDDDDldRuuuuuuuuuurrrrrrrrrrrrrdddddddddlllllllllluuuuuurrrrDDllddr\nUUdRRRdrUUUlDuuurrdLdddLLLulUruLLLulDDDDDDldRRRRRRRRRRdrUUUUUUUUUruLLLLLLLLLLLLL\nulDDDDDDDDDDuuuuuuuuurrrrrrrrrrrrrdddddddddlllllllllluuuuuurrrddlddrUUUruLLLulDD\nDDDDldRRRRRRRRRRdrUUUUUUUUUruLLLLLLLLLLLLLulDDDDDDDDDuuuuuuuurrrrrrrrrrrrrdddddd\ndddlllllllllluuuuuurrrdddrrruuruulDDDrdLLLullddrUUUruLLLulDDDDDDldRRRRRRRRRRdrUU\nUUUUUUUruLLLLLLLLLLLLLulDDDDDDDD\n14102.903747797012 seconds\n```\n\nThere is still enough room for improvements...\n\n## Links and Third Party\n\n* https://en.wikipedia.org/wiki/Sokoban\n\nDue to its popularity there are free level collections available in the community.\nA huge and widely spread level collection has been created by David W. Skinner\nnamed Microban and Sasquatch.\n\n* http://www.abelmartin.com/rj/sokobanJS/Skinner/David%20W.%20Skinner%20-%20Sokoban.htm\n\nVarious level formats have been defined that are used in the community.\nThese simplify to use the same level files in different Sokoban implementations.\n\n* http://www.sokobano.de/wiki/index.php?title=Level_format\n\nMore Sokoban resources, links and information...\n\n* http://www.sokobano.de\n\nDart programming language\n\n* https://dart.dev\n* https://dart.dev/tools/sdk\n\n## Contributors / Authors\n\nOliver Merkel\n\n_All logos, brands and trademarks mentioned belong to their respective owners._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerkel%2Fsokoban","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomerkel%2Fsokoban","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerkel%2Fsokoban/lists"}