Sente: a Python 3 native library for the game of Go.
Project description
Sente (from the Japanese せんて/先手) is a general-purpose open-source python library for the ancient chinese board game Go/Badok/Weiqi. It allows for python code to simulate and play a game of Go and also read, edit and create SGF files. 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 text created by printing a Sente board is designed to be similar to the gomill ascii boards output. Unlike Gomill however, Sente uses unicode characters to represent black and white stones to make complex board positions more visible and also plots star points.
Finally, Sente also provides utilities for reading and saving SGF files using the sente.SGF
module
>>> from sente import sgf
>>> game = sgf.load("Lee Sedol ladder game.sgf")
>>> move_sequence = game.get_default_sequence()[:95]
>>> game.play_sequence(move_sequence)
>>> 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
Further Reading
- Game Trees
- SFG file reader
- NumPy conversion
- GTP (Go Text Protocol) (Coming Soon!)
- Automatic Dead Stone removal (Coming Soon!)
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
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
Built Distributions
Hashes for sente-0.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 558c308573db720fab7b669810f0c66f3487c9b3cb6e255e1bdb80de4a003e6b |
|
MD5 | 0bbc0c44b1861999d068932fb74d14d7 |
|
BLAKE2b-256 | 744740510a00fd26eb63429926a5ae5ff5645f3f55a3592e45d7d3f20c395bc8 |
Hashes for sente-0.3.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142cf2dec93ded89c5bfec23cbeeb78fdaf93d4b6421c72838b90b39fb4c1b49 |
|
MD5 | ad357a1c0115b60007f5ecfb7ddd0514 |
|
BLAKE2b-256 | 24f689c2947dd876344215f5289d349af9293257d91b52b9f0a0fbda18dda418 |
Hashes for sente-0.3.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6920ad16d0e2357306192e6d45ae5d3045b92bb7b40a25d312fef0d5f56ba1c |
|
MD5 | 4600a8bcf7f819b48a509da022b93fc7 |
|
BLAKE2b-256 | 15d9c395e5f57f0f564ba0681ad09ee98a1144c847ecbfc5c199dad2b3801e14 |
Hashes for sente-0.3.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7feb44068b99ca179962314c0ad144e8cdf098d63ed68d8e3017d4f3bccb3d9d |
|
MD5 | 2a41e7815b9fa437cf2686b9af17b190 |
|
BLAKE2b-256 | 4f35e795f75aa7c7d65b45c1355a33ac917ca78249e0f997e062a79b96fdeeb9 |
Hashes for sente-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c3d23c6b9bb24fc330c6a2625233749a61739792bd95ef9feb96507d063a169 |
|
MD5 | 69a4a2fd9f5e2f18c05d27b992493ef3 |
|
BLAKE2b-256 | 418c462a8bea5db94a03d1091ab6844a34018b0f19d813e3ec691668abe8daa3 |
Hashes for sente-0.3.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fdd88a728f3f860e71d3a1e5f56697003d6c4de0183f237dda0c7db5f1086fb |
|
MD5 | ac63922c623c85b0d640f611d79cfd2b |
|
BLAKE2b-256 | 4fe3af69ac11e1c50fe7d323febbf2ef74c10bed41dd0c71c694f4206e06eb2c |
Hashes for sente-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8812b7ed499cc0062a01f0f81d525b20d8b3775329f110f70f2427200b97a259 |
|
MD5 | 05b5d6eaa31f2be62010158ec9571c97 |
|
BLAKE2b-256 | b73fc9386fc99d6ad5d0794809512ebb7ddf0e090984a5213ac54124964b1f3c |
Hashes for sente-0.3.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b4978d30764883c276ef45e9b7d5da2971fc4759e12f42e5727e68327cd9dc |
|
MD5 | a9a5ba11269574096b216867ce7de3f2 |
|
BLAKE2b-256 | 614d9bb5bdba676e3cb4c78fd3d03c933bf1895a9c73258171136ee6260188e4 |
Hashes for sente-0.3.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459e10cbfb972e3faaa2a322cb308fda8f93480e1902c102a38b5aa8192ce952 |
|
MD5 | d88fbcb33a9a0b8dc6272b110ffab777 |
|
BLAKE2b-256 | 536a99b4a0ea2ac0169d4e8412410ca5f393f2c0ec238d676895ab873268fe10 |
Hashes for sente-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0c6a02235ea99c2b5f97f2c578c88b8d43aad59369d8846af0d9a303bbeebe4 |
|
MD5 | c026898fd15d43f4ca1c02e01e7dc931 |
|
BLAKE2b-256 | 4e1a51d132e49a0c2dc34b3a0a30a512c0de74ad5e506e5278318bbf88a50a50 |
Hashes for sente-0.3.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7b2453e0e1b7e87c8a1163e1d41dfb4238f5ca2011105eed79ec2663418b51a |
|
MD5 | 04e53560407c4ff6ec158d3fcb48e095 |
|
BLAKE2b-256 | 388f983be8f1938fe9e9a141c6f73b0f3118df123b31c706b2b1ceacbc540489 |
Hashes for sente-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50caab07dfbaf61d0aa7762643af8b7554ccf7140bfddacb92b6e81b1b44a5ed |
|
MD5 | 713a4ce284dc68e886f533647c1ccbfd |
|
BLAKE2b-256 | a727f3b32e242c6fc36b647994210fa9d3ea9ddc77b19700a653ccd254ac70a8 |
Hashes for sente-0.3.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23c57861a553f9da42e4592a81e4daa66b64bb66e22dc848be9c9c9aed61c47b |
|
MD5 | 0648035d923cfb61c230cda24c671da0 |
|
BLAKE2b-256 | c9964cbb921453513520f639bfd60965a86b97257da65906ec812df72d3075ee |
Hashes for sente-0.3.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84df11d79392debe0660cb890675409129a64c288274b4beba91235ca2e9f131 |
|
MD5 | 9f2c98a58a56d52c94af50b0a39940a5 |
|
BLAKE2b-256 | 916a2b1d1f4c8bcec7a235ef473e543077566e0374677e706797cf27e7a644ba |
Hashes for sente-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71683b7cf79a19b933d25e73dc7a069d593b41a32c3a0f7795be07ac6f1156a6 |
|
MD5 | 316bfbf1a03b4edf0fd50b2a08689dcf |
|
BLAKE2b-256 | 8c138bdadbae3cbdd0b032bc50fb06396114b65b8a98571902dfaa2f6a946e9b |
Hashes for sente-0.3.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50fe498ea6b1e8cb99bf8b25571163504faf056d0aee0b9f188724e78071e078 |
|
MD5 | e4c478f03e65e03b596dd34df55e2846 |
|
BLAKE2b-256 | 4d9ff6859db08324e4db39d07691d32a399cc4049f307a628add3c9f05338281 |