Sokoban and variants game utilities
Project description
sokoenginepy - Sokoban and variants
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 implementationlibsokoengine
- C++ library
Example
In Python:
import textwrap
from sokoenginepy.io import SokobanPuzzle
from sokoenginepy.game import BoardGraph, Mover, Direction, Config
data = textwrap.dedent("""
#####
# @#
#$ #
### $##
# $ $ #
### # ## # ######
# # ## ##### ..#
# $ $ ..#
##### ### #@## ..#
# #########
#######
""".lstrip("\n").rstrip())
puzzle = SokobanPuzzle(board=data)
board = BoardGraph(puzzle)
mover = Mover(board)
mover.select_pusher(Config.DEFAULT_PIECE_ID + 1)
mover.move(Direction.UP)
or in C++:
#include <sokoengine.hpp>
using sokoengine::game::BoardGraph;
using sokoengine::game::Direction;
using sokoengine::game::Mover;
using sokoengine::game::Config;
using sokoengine::io::SokobanPuzzle;
using std::string;
int main() {
string data =
string() +
" #####\n" +
" # @#\n" +
" #$ #\n" +
" ### $##\n" +
" # $ $ #\n" +
"### # ## # ######\n" +
"# # ## ##### ..#\n" +
"# $ $ ..#\n" +
"##### ### #@## ..#\n" +
" # #########\n" +
" #######\n"
;
SokobanPuzzle puzzle(data);
BoardGraph board(puzzle);
Mover mover(board);
mover.select_pusher(Config::DEFAULT_PIECE_ID + 1);
mover.move(Direction::UP);
return 0;
}
Install
sokoenginepy
package from PyPi:
pip install sokoenginepy
or libsokoengine
C++ library:
sudo apt install git build-essential libboost-graph-dev cmake doxygen
git clone https://github.com/tadams42/sokoenginepy.git
cd sokoenginepy/
cmake --preset "debug"
cd build/debug/
make && make install
On Linux, installing package via pip
will also try to build native C++ extension that
utilizes libsokoengine
for improved speed. In case it can't build, it will install
pure Python implementation. On any other OS, pip
will install pure Python only.
For more elaborate details, see INSTALL.md
Why?
- experimenting with Boost.X3 in C++
- experimenting with Boost.Graph in C++
- experimenting with NetworkX in Python
- experimenting with pybind11
- playing with SokobanYASC
.sok
file format and providing fully compatible implementation for it in both, Python and C++
Documentation
- Tutorial: Read the Docs - Tutorial
- Python docs: Read the Docs
- C++ docs: libsokoengine Doxygen documentation
If you're looking for C++ docs in Doxygen format, they are here:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sokoenginepy-0.6.0.tar.gz
(1.5 MB
view hashes)
Built Distribution
Close
Hashes for sokoenginepy-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d5c39c480c54b7c099df2b5ba4031f942fa4877aa99699940fcd55d4188c5e5 |
|
MD5 | 17d49d662122284b6b92259ff4f36f00 |
|
BLAKE2b-256 | 09253197c4bef64e78130871c2e4c6ddf4755e348d4b7cbb4ec9d8b481242b16 |