sokoenginepy - Sokoban and variants#

badge - PyPi version badge - Python versions badge - C++ version badge - CI - tests badge - ReadTheDocs build badge - C++ docs badge - Codecov badge - license

This project implements various utilities for Sokoban:

  • board representation for Sokoban, Hexoban, Trioban and Octoban variants with support for Sokoban+ and Multiban for all four variants

  • game engine implementation

  • SokobanYASC compatible level collections file reader / writer

It provides two implementations:

  • sokoenginepy - pure Python implementation

  • libsokoengine - C++ library

Documentation#

Example#

In Python:

import textwrap
from sokoenginepy import Config, Direction, Tessellation, Puzzle, BoardGraph, Mover

data = textwrap.dedent("""
        #####
        #  @#
        #$  #
      ###  $##
      #  $ $ #
    ### # ## #   ######
    #   # ## #####  ..#
    # $  $          ..#
    ##### ### #@##  ..#
        #     #########
        #######
""")
puzzle = Puzzle(Tessellation.SOKOBAN, board=data)
board = BoardGraph(puzzle)
mover = Mover(board)
mover.select_pusher(Config.DEFAULT_ID + 1)
mover.move(Direction.UP)
print(board)

or in C++:

#include <sokoengine.hpp>

#include <iostream>

using sokoengine::BoardGraph;
using sokoengine::Config;
using sokoengine::Direction;
using sokoengine::Mover;
using sokoengine::Tessellation;
using sokoengine::Puzzle;
using std::string;

int main() {
  string data = R"""(
    #####
    #  @#
    #$  #
  ###  $##
  #  $ $ #
### # ## #   ######
#   # ## #####  ..#
# $  $          ..#
##### ### #@##  ..#
    #     #########
    #######
)""";

  Puzzle puzzle(Tessellation::SOKOBAN, data);
  BoardGraph board(puzzle);
  Mover mover(board);
  mover.select_pusher(Config::DEFAULT_ID + 1);
  mover.move(Direction::UP);

  std::cout << board.str() << std::endl;

  return 0;
}

Install#

sokoenginepy package from PyPi:

pip install sokoenginepy

or libsokoengine C++ library:

You will need vcpkg and then:

sudo apt install git build-essential cmake doxygen

git clone https://github.com/tadams42/sokoenginepy.git
cd sokoenginepy/

export CMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
cmake --preset "debug"

cd build/debug/
make && make install

For more elaborate details, see INSTALL.md

Why?#

Tables of contents and indices#