Skip to main content

Sente: a Python 3 native library for the game of Go.

Project description

PyPI version docs pip wheels

Sente (from the Japanese せんて/先手) is a general-purpose open-source python library for the ancient chinese board game Go/Badok/Weiqi. Sente is designed to be a Python 3 replacement for the gomill library.

In addition to supporting Python 3, Sente is written in C++ which allows AIs that use Sente to take advantage of C++'s superior performance.

Installation & Requirements

Sente runs on any operating system with python 3.5, 3.8 and 3.9 and can be installed via pip.

$ pip install sente

-- or --

$ python3 -m pip install sente

Getting Started

The Basic element in Sente is the sente.Game object which represents a Simple Game.

>>> import sente
>>> game = sente.Game()

By default, sente creates a 19x19 game with Chinese Rules. 9x9 and 13x13 board sizes and Japanese rules can be specified if desired.

note: japanese rules are not reccomended as sente does not currently include automatic dead stone removal.

>>> game = sente.Game(13)
>>> game = sente.Game(19, sente.rules.JAPANESE)

moves can be played on the game using the play() method, and the board can be printed using the python print() function.

>>> game.play(4, 4)
>>> game.play(16, 4)
>>> game.play(4, 17)
>>> print(game)
 1  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 2  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 3  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 4  .  .  .  ⚫ .  .  .  .  .  *  .  .  .  .  .  *  ⚫ .  .
 5  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 6  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 7  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 8  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 9  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
10  .  .  .  *  .  .  .  .  .  *  .  .  .  .  .  *  .  .  .
11  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
12  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
13  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
14  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
15  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
16  .  .  .  ⚪ .  .  .  .  .  *  .  .  .  .  .  *  .  .  .
17  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
18  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
19  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
    A  B  C  D  E  F  G  H  J  K  L  M  N  O  P  Q  R  S  T

The Sente board display is designed to be similar to the gomill ascii boards output. A hash (#) denotes a Black stone and an "O" (O) denotes a white stone. One difference between sente and gomill is that in sente, the star points are denoted using an asterisk (*)

Finally, Sente also provides the ability to check if a move is legal using the is_legal() method

>>> import sente
>>> game = sente.Game()
>>> game.play(4, 4)
>>> game.is_legal(4, 4)
False

Further Reading

Building & Contributing

Sente uses CMake, git and C++11. In order to build the library, you will need CMake, and a C++ compiler that supports C++11. You can install these using a software package installer like homebrew or apt.

OSx

$ brew install git
$ brew install cmake
$ brew install clang++

Debian/Ubuntu

$ sudo apt-get install git
$ sudo apt-get install cmake
$ sudo apt-get install g++

A sente binary can be built by running the setup script.

$ python3 setup.py develop

To import the resulting .so file, simply import sente in a local python interpreter

$ python3 setup.py develop
$ python3
Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 09:09:08) 
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sente
>>> 

Building documentation

in order to build the documentation, you will need to have sphinx installed and build a development version of sente.

$ pip install -r requirements.txt # install sphinx
$ python setup.py develop # build a development version of sente
$ cd docs
$ make html # make the html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sente-0.2.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distributions

sente-0.2.0-cp310-cp310-win_amd64.whl (188.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

sente-0.2.0-cp310-cp310-win32.whl (136.5 kB view hashes)

Uploaded CPython 3.10 Windows x86

sente-0.2.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (233.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

sente-0.2.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl (245.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686

sente-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (205.7 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sente-0.2.0-cp310-cp310-macosx_10_9_universal2.whl (390.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

sente-0.2.0-cp39-cp39-win_amd64.whl (180.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

sente-0.2.0-cp39-cp39-win32.whl (136.5 kB view hashes)

Uploaded CPython 3.9 Windows x86

sente-0.2.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (233.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

sente-0.2.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (246.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

sente-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (205.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

sente-0.2.0-cp39-cp39-macosx_10_9_universal2.whl (391.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

sente-0.2.0-cp38-cp38-win_amd64.whl (188.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

sente-0.2.0-cp38-cp38-win32.whl (136.4 kB view hashes)

Uploaded CPython 3.8 Windows x86

sente-0.2.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (233.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

sente-0.2.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (245.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

sente-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (205.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

sente-0.2.0-cp38-cp38-macosx_10_9_universal2.whl (390.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page