Code Monkey home page Code Monkey logo

elm-sokoban-player's Introduction

Sokoban Player

Sokoban Player provides best experience to play any sokoban level you want!

Play it here

Contributing

This app is based on create-elm-app. Here are steps to set it up for yourself.

  • npm install
  • npm start

To build app

  • npm run build

To build SVG sprite

  • npm run build-svg

Run tests (optional with watch)

  • npm test
  • npm test -- --watch

Pull requests are welcome!

Some docs

Level data structures and transformations

StringLevel and ShortStringLevel

Based on Sokoban Level Format level can be defined as a string in 2 formats, normal and short. This is one of possible entry formats.

  • StringLevel - normal, row separation with pipe or just with new line
#######
#.@ # #
#$* $ #
#   $ #
# ..  #
#  *  #
#######
  • ShortStringLevel - created from normal with Run Length Encoding, row separation obligatory with pipe, underscore represents an empty field
7#|#.@_#_#|#$*_$_#|#3_$_#|#_2.2_#|#2_*2_#|7#|
  • XmlLevel

XML Sokoban format, game elements are represented with the same characters as in string format. Another entry format.

<Level Id="soko42" Width="7" Height="9">
    <L> ######</L>
    <L> #    #</L>
    <L>## $  #</L>
    <L>#  ##$#</L>
    <L># $.#.#</L>
    <L># $...#</L>
    <L># $####</L>
    <L>#@ #</L>
    <L>####</L>
</Level>
  • Level

Intermediary structure to standardize all entry formats. id is a EncodedLevel

level : Level
level =
    { width = 5
    , height = 3
    , map =
        [ [ '#', '#', '#', '#', '#' ]
        , [ '#', '@', '$', '.', '#' ]
        , [ '#', '#', '#', '#', '#' ]
        ]
    , id = "5AHABDFAH5A"
    }
  • ViewLevel

Is created always directly from Level and is used to keep and update level elements in Model.

viewLevel : ViewLevel
viewLevel =
    { player = Block 1 1
    , walls = [ Block 0 0, Block 1 0, etc. ]
    , boxes = [ Block 2 1 ]
    , dots = [ Block 3 1 ]
    , gameSize = ( 5, 3 )
    }
  • EncodedLevel

This is ShortStringLevel format mapped to more url-friendly symbols, see table below.

7AHAFBGAGAHADEGDGAHA3GDGAHAG2F2GAHA2GE2GAH7AH
element sokoban format url encoded
wall # A
player @ B
player on dot + C
box $ D
box on dot * E
dot . F
floor _ G
row separator | H

License

(c) Copyright 2018 Kris Urbas @krzysu, all rights reserved.

This game is open sourced for learning and recruitment purposes. Do not use for profit!

Original Sokoban game written by Hiroyuki Imabayashi © 1982 by THINKING RABBIT Inc. JAPAN.

Game assets by Kenney.nl.

elm-sokoban-player's People

Contributors

dependabot-preview[bot] avatar

Stargazers

kirillfgssfg avatar  avatar Ganesh Khaire avatar Didier Marin avatar  avatar Shamis Shukoor avatar Andrey Kuzmin avatar Jonas Schürmann avatar

Watchers

Kris avatar James Cloos avatar

elm-sokoban-player's Issues

render level from sokoban xml format

something like

<Level Id="soko1" Width="7" Height="7">
      <L>#######</L>
      <L>#.   .#</L>
      <L># $$# #</L>
      <L># $ #@#</L>
      <L>##$ # #</L>
      <L>#.  . #</L>
      <L>#######</L>
</Level>

or

<Level Id="soko16" Width="7" Height="9">
      <L>   ###</L>
      <L>####@#</L>
      <L>#.   ##</L>
      <L>#. *  #</L>
      <L>#. #$ #</L>
      <L>##$#  #</L>
      <L> # $ ##</L>
      <L> #   #</L>
      <L> #####</L>
</Level>

where:
# - wall
@ - player
. - placeholder
$ - box
* - box on placeholder

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.