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
Documentation
- Tutorial: Read the Docs - Tutorial
- Python docs: Read the Docs
- C++ docs: libsokoengine Doxygen documentation
Example
In Python:
import textwrap
from sokoenginepy.io import SokobanPuzzle
from sokoenginepy.game import BoardGraph, Mover, Direction, Config
data = textwrap.dedent("""
#####
# @#
#$ #
### $##
# $ $ #
### # ## # ######
# # ## ##### ..#
# $ $ ..#
##### ### #@## ..#
# #########
#######
""")
puzzle = SokobanPuzzle(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::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 = R"""(
#####
# @#
#$ #
### $##
# $ $ #
### # ## # ######
# # ## ##### ..#
# $ $ ..#
##### ### #@## ..#
# #########
#######
)""";
SokobanPuzzle puzzle(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?
- 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++
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-1.0.3.tar.gz
(1.5 MB
view details)
Built Distribution
File details
Details for the file sokoenginepy-1.0.3.tar.gz
.
File metadata
- Download URL: sokoenginepy-1.0.3.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2130ed9fe3e16e3327930966905d36eaa6ba7e852e581ad9d650468d3d85059c |
|
MD5 | da1ba64bdd49b5b9577e88a6ae491fa7 |
|
BLAKE2b-256 | 514a7713ec05463ddd20907507fab17cf2790e9b2bd37c3d5047973ceb9263f0 |
File details
Details for the file sokoenginepy-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: sokoenginepy-1.0.3-py3-none-any.whl
- Upload date:
- Size: 77.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93add14485c5670300843ecf5d71ce923b47c9cb391b2d361a5bbc5fbcac5f5f |
|
MD5 | 67ac6eac8023821d1295f940e783949d |
|
BLAKE2b-256 | a81d31261d0407aa2398ada80f9112a6daa27806e6480d1b908022f82f86f1bf |