sponsor Vim development Vim logo Vim Book Ad

sokoban.vim : Sokoban Game for Vim!

 script karma  Rating 682/191, Downloaded by 10433  Comments, bugs, improvements  Vim wiki

created by
Mike Sharpe
 
script type
game
 
description
The goal of VimSokoban is to push all the packages ($) into the  home area (.) of each level using hjkl keys or the arrow keys.
The arrow keys move the player (X) in the  corresponding direction, pushing a package if it is in the way and there is a clear
space on the other side.

Use the
:Sokoban       - or -    :Sokoban <level num>     (no split window)
:SokobanH     - or -    :SokobanH <level num>   (horizontal split window)
:SokobanV     - or -    :SokobanV <level num>   (vertical split window)
commands to start the game

h or <Left> - move the man left
j or <Down> - move the man down
k or <Up> - move the man up
l or <Right> - move the man right
r - restart level
n - next level
p - previous level
u - undo move

Levels came from the xsokoban distribution which is in the public domain.
http://www.cs.cornell.edu/andru/xsokoban.html

Take a look at VIM Tetris (vimscript#172) too....the game which started the VIM Game revolution :)
 
install details
Run `tar -zxf VimSokoban.tar.gz`, this will unpack the installation into the VimSokoban directory. Contained in that directory
are the levels and the sokoban.vim script. Simply add sokoban.vim to your favorite vim plugin directory or source it directly.  
The directory containing the levels is found as follows,
1) if g:SokobanLevelDirectory is set that directory is used
2) if $VIMSOKOBANDIR is set that directory is used
3) if $HOME/VimSokoban exists it is used
4) on WINDOWS, if c:\\VimSokoban exists it is used
5) if a VimSokoban directory exists below the directory where the script lives exists it is used. (this means that if sokoban.vim
    is in your plugin directory you can put the levels into a directory called VimSokoban in your plugin directory)
6) Finally, the directory where the script lives is considered. (this means that if you have the levels and the sokoban.vim
    script in the same directory it should be able to find the levels)

(when setting g:SokobanLevelDirectory or $VIMSOKOBANDIR make sure that it contains a trailing / or \ (unix/windows).

You will need a VIM window which is 80 characters wide and about 35 lines.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
VimSokoban.tar.gz 1.3 2002-03-06 6.0 Mike Sharpe set buftype and nomodifiable, remeber progress though levels, record high scores for each level.
VimSokoban.tar.gz 1.2 2002-02-21 6.0 Mike Sharpe fix bug in routine which detected when a level was complete. This meant some levels were not detected as complete e.g. level 11.
VimSokoban.tar.gz 1.1b 2002-02-19 6.0 Mike Sharpe Use the <sfile> expansion to try to locate the level directory.
VimSokoban.tar.gz 1.1a 2002-02-15 6.0 Mike Sharpe Minor tweaks to help windows find the level
directory a little more smoothly. I hope this works.
VimSokoban.tar.gz 1.1 2002-02-13 6.0 Mike Sharpe Map the j/k keys correctly.
Added SokobanH and SokobanV commands which control how the screen is split
VimSokoban.tar.gz 1.0 2002-02-11 6.0 Mike Sharpe Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github