Skip to main content

Python bindings for the rshogi core library.

Reason this release was yanked:

Project renamed to rsshogi. Use rsshogi instead.

Project description

rshogi-py

Python bindings for the rshogi Rust crate.

This package provides the standard build of the rshogi Python module. Use this package by default. If you have an AVX2-capable x86_64 CPU and want the AVX2-optimized build, use rshogi-py-avx2.

Development Install

python -m pip install maturin
maturin develop -m crates/rshogi-py/pyproject.toml

AVX2 Build

rshogi-py-avx2 is an AVX2-enabled build of the same Python module for AVX2-capable x86_64 CPUs.

python -m pip install rshogi-py-avx2

Notes

  • rshogi-py and rshogi-py-avx2 are mutually exclusive; install only one.
  • rshogi-py is the safest default for broad compatibility.
  • policy 学習向けの move label 変換は rshogi.policy から利用できます。

Policy Labels

from rshogi.core import Move
from rshogi.policy import compact_move_label, move_label
from rshogi.types import Color

mv = Move.from_usi("7g7f")

label = move_label(mv, Color.BLACK)
compact = compact_move_label(mv, Color.BLACK)

print(label)    # 2187 クラス
print(compact)  # 1496 クラス or None

Quick Example

from rshogi.core import Board

board = Board()
board.apply_usi("7g7f")
print(board.to_sfen())

raw-state を Python から直接編集することもできます。

from rshogi.core import Board
from rshogi.types import Color, Piece, PieceType, Square

board = Board()
state = board.to_position_state()
state.set_piece(Square.from_usi("7g"), Piece(0))
state.set_piece(Square.from_usi("7f"), Piece.from_color_type(Color.BLACK, PieceType.PAWN))
state.ply = 42

board.set_position_state(state)
report = board.validate_all()
print(board.to_sfen())
print(report.is_valid())

USI の position 文字列を直接扱うこともできます。

from rshogi.core import Board, normalize_usi_position, parse_usi_position

board = Board()
board.set_usi_position("position startpos moves 7g7f 3c3d")

board2 = parse_usi_position("startpos moves 7g7f")
print(board2.to_sfen())

print(normalize_usi_position("position startpos"))  # "startpos"

cshogi / Apery Compatibility

rshogi can interoperate with cshogi / Apery move and training-data formats.

from rshogi.core import Board, Move

board = Board()
move = Move.from_usi("7g7f")

apery = move.to_apery()
apery32 = board.apery_move32_from_move(move)
hcpe = board.to_hcpe(best_move=apery, score=120, game_result="BLACK_WIN")

print(int(apery))
print(apery32.to_usi())
print(len(hcpe))  # 38

Structured Imports

rshogi provides structured imports through submodules for better organization:

# Types and constants
from rshogi.types import Color, PieceType, Square
from rshogi.core import Move, Move32, AperyMove, AperyMove32

# Board
from rshogi.core import Board, PositionState, ValidationIssue, ValidationReport

# Records
from rshogi.record import GameRecord, GameRecordMetadata, GameResult

# Record conversion
record = GameRecord.from_kif_str(kif_text)
kif_text = record.to_kif()

# Record file I/O
record = GameRecord.from_kif_file("example.kif")
record.write_kif("example_out.kif")

# NumPy dtypes
from rshogi.numpy import (
    PackedSfen,
    PackedSfenValue,
    HuffmanCodedPos,
    HuffmanCodedPosAndEval,
)

# Policy labels
from rshogi.policy import move_label, compact_move_label

Use submodules for all imports:

from rshogi.core import Board
from rshogi.core import Move
from rshogi.record import GameRecord

Record I/O Notes

GameRecord の棋譜 I/O は Rust core と同じ互換方針で動作します。

  • KIF/KI2 は ShogiHome/tsshogi 系の実務互換と shogi-validator 寄りの整形を意識しています。
  • 変化手順と終局要約が同居する場合、to_kif() / to_ki2()変化:... を先に、 まで... を最後に出力します。
  • from_kif_str() / from_ki2_str() で読んだ初手前コメントは GameRecord.initial_comment に保持され、to_kif() / to_ki2() で 1 手目の前に戻ります。
  • from_csa_str() / from_csa_file() は CSA 3.0 に合わせて '*comment だけを プログラムが読むコメントとして受理し、plain な 'comment は読み飛ばします。 受理した開始局面コメントは GameRecord.initial_comment に保持されます。
  • 互換性のため、手番行より前にある '*commentinitial_comment に正規化して受理します。
  • GameRecordMetadata.comment は自由コメントではなく、KIF の 備考 / CSA の $NOTE / JKF header の 備考 に対応します。
  • to_csa() は move comment と初期局面コメントを '*comment として出力し、 write_kif() / write_ki2() / write_csa() は末尾改行つきで書き出します。

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

rshogi_py-0.10.0.tar.gz (347.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rshogi_py-0.10.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (850.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.10.0-cp314-cp314-win_amd64.whl (775.1 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.10.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (876.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.0-cp314-cp314-macosx_11_0_arm64.whl (795.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.10.0-cp313-cp313-win_amd64.whl (757.3 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (858.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.0-cp313-cp313-macosx_11_0_arm64.whl (777.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.10.0-cp312-cp312-win_amd64.whl (756.3 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (858.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.0-cp312-cp312-macosx_11_0_arm64.whl (776.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.10.0-cp311-cp311-win_amd64.whl (748.4 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (851.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.0-cp311-cp311-macosx_11_0_arm64.whl (783.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.10.0-cp310-cp310-win_amd64.whl (748.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (851.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file rshogi_py-0.10.0.tar.gz.

File metadata

  • Download URL: rshogi_py-0.10.0.tar.gz
  • Upload date:
  • Size: 347.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0.tar.gz
Algorithm Hash digest
SHA256 06184d5a043302c6502775f5e949304fb5f63a43ea82d3fbb118b0be39d654a4
MD5 cfaac5e6ae36c7530440f2f1621c9cf5
BLAKE2b-256 3dd2071106a7085486220a3d3a93d79f3fa7a0c7e391d8c70ff373c2a213558a

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82a9c6d7d26fa575662683b3359ac6d09d90eac9f1240e8a67ae57651bf5ce78
MD5 c7d05a77547efaee195090319c07312e
BLAKE2b-256 0b9dde5ea9dc98f924646e3814ddb38e3d2325bb64df306d91a7eaf887a0fa50

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: rshogi_py-0.10.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 775.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 411483665adb7fb8eca492f734140f20d3dd811df60c475e200aeeea76a850e7
MD5 86784e1f38d528b87283fe263d872fc5
BLAKE2b-256 ccfa17884aa51625e0eb4574fb58533729eab2c1f6f88f9ed3980298d6be2343

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9727233fdc243ea9bdb7c185b0c6017200e89d0a7583b5754bf9b7b59d0d0161
MD5 7d7915027c82b3eea492dd839829f52b
BLAKE2b-256 11ced6a9927d58d341714e4d2e2c4aa7620ee3f5e6e97de2a6224bfc0534be31

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c47dfcdc02cd540fa3667bce27944a21b7cd94cc5ecc4dd25e883c243cd73657
MD5 efafade2eef76060969e2b28fbb0d1f7
BLAKE2b-256 e69921d2af90ed2ef99ce6b560245154226747bd4e18ee82a0ac8a716f0847c2

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rshogi_py-0.10.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 757.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c55053bd0302a626a0e9ef0908e29eaa5bf9279e966537cf6a38e55f69c0d50f
MD5 044a2aedd88ad3f286e1b58f68f9baed
BLAKE2b-256 17ce7886c2a422f06c0c5b2917a9fb5b774321ca1d8ec88d84e7092e13dc92fe

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 552fef7d8b94ddbafe369dfa2b3c505dbb3bd8aac969457d08fa3cc4b930ff32
MD5 d69e6c3cb02c93f1967acca0f643ee06
BLAKE2b-256 e3a7d066d6a0cebd9ef0be9896fb2a5c787424b4f094eb7210bb49b8cb734815

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee75ea70b3ad62fed8437c8378aef3c4df8d8f414b09e4c29209d2d321e19917
MD5 25e3b22fdc1b3ec42f22b1342d96f119
BLAKE2b-256 2ed3fe4056cfe7fe82842cb9fd2d399d91764b52fb4a1988564d2533f94c84b5

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rshogi_py-0.10.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 756.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 11901482dc4279b75f0616d0224dfeca21d0313f288c210ec8238f01a07171fa
MD5 4e68cc03906219d663c444bdf2de35df
BLAKE2b-256 e72e1fe21f55ca8442493adc4f61227d0dbca04805e8b93373f6d8de5ad55383

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b575acfe4589e3031d1c0725363941a3df8e26dde7bd667cb430a842e30e11d
MD5 16734e130921f25e64a239cafa913be5
BLAKE2b-256 6eb9d5590d3d8a786b374ac9fcbf8afcac0d87e5918ecd4d815fbed4f501b764

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c378680cfa84e6dd914d8eb9ac19536fb1d25ceddb9dba26ea3f4d3d2e30e34
MD5 11202c93b65d0ff5c4cb55fd25fbd474
BLAKE2b-256 d436fda9dfb66299858ae344a41198810d22b44354087966ca49d4406e087627

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rshogi_py-0.10.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 748.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 89ca636f17fd2c8eb01cd342f430a08cf014c6b414d06bbfc4d1008f601a1302
MD5 882b487f6f92682c2c8a04013126160d
BLAKE2b-256 230fe3819b47fcd650144796ed3b1633ce0a77d9083808c19e322f2670409865

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80a4fbf3a85cfc1846edf5f61fa3a14c13d030eebd253399142e8f32c489560b
MD5 78f195dc65c32d40a6ae37c48fe7f456
BLAKE2b-256 e1389dfdea4c70bac7be648f3b2bd9290e8681a864d8775775fa9f18e2b4b0f1

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f369868b93212cb52377ede017d3dcdfdcd0dea62fbb463857270e3458a8cf1d
MD5 39eab827cf845d37d9472aa23905a54f
BLAKE2b-256 68ab53f52240c2a2f035923004eb8ae7058abb5c02e7163a00a284599879eca9

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rshogi_py-0.10.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 748.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rshogi_py-0.10.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d337b5e649849e48e5f08627341927e263a4e3ef4f5e16cc6ed609ecde32f5d0
MD5 4157ab0b639e766a2bac740ed9c2ffa5
BLAKE2b-256 75388301718cb08c57fdaa90d2ca1edab487d6a7eb9a9c88a437d9367d46162e

See more details on using hashes here.

File details

Details for the file rshogi_py-0.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rshogi_py-0.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f27ddfe3a236964155451cf56699c0c2abcfc8d428e7127012b457684426b88d
MD5 bb059a173efabce4b503cdc3490b9972
BLAKE2b-256 eb833cd993f04fae97087f94e3cce09e897f9a147d361e7d8394d9e8abe22cc2

See more details on using hashes here.

Supported by

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