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. If you want an 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.

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.7.12.tar.gz (329.4 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.7.12-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (889.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.12-cp314-cp314-win_amd64.whl (751.6 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.12-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.12-cp314-cp314-macosx_11_0_arm64.whl (842.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.12-cp313-cp313-win_amd64.whl (734.3 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.12-cp313-cp313-macosx_11_0_arm64.whl (823.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.12-cp312-cp312-win_amd64.whl (733.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.12-cp312-cp312-macosx_11_0_arm64.whl (822.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.12-cp311-cp311-win_amd64.whl (726.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.12-cp311-cp311-macosx_11_0_arm64.whl (831.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.12-cp310-cp310-win_amd64.whl (726.1 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12.tar.gz
  • Upload date:
  • Size: 329.4 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.7.12.tar.gz
Algorithm Hash digest
SHA256 55dcd683c53b213425d299b72b1429bb0419023a63f4fd4997071a8b14a23eca
MD5 c2b056a9866074668ef2fcdd99335503
BLAKE2b-256 dc37cc6351ad56647ed28f9be806c2ea2da3ada9c23840ac65aa77757a7b24c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5bdbde09cb35ce375d8898dae627957b9b065d38c3dd022f6ed0efa753e8875
MD5 693594e901a9c44e7c67985c16bfd1fe
BLAKE2b-256 11461b9ec2e6ecf82a8cadafd58d5280aa88e8dec787d28c1765be1de14d89bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 751.6 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.7.12-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6bd1f81575c545a711d1f5f8d17d306e24b9570212192b1ea3f1039745bf648b
MD5 6168a3b0815cfae4a85353d95a1a16fd
BLAKE2b-256 33b6d3a73288db0521c11040f03ba68feb1d0bb69d07d3374ace17589e89070d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f8132977465ff753bd46b7906785456d976c9891f9160e0c02b34c1ed7c34e2
MD5 6796645eff640b5b9e65a15a47927795
BLAKE2b-256 0a9c94f6905280e27c6213d89fc84790648b90fe368c7bee1f0ca04891b9dd26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bc14a5052ebe9f76013d44ce21bd4cd7740480e61462cb93bab79b043f46c35
MD5 b67881620e540ac4be3a128d569023ab
BLAKE2b-256 ab34e73e34dedfeea2968ac313f905db3e0548618fa2fc8297a43eb61b5898ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 734.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.7.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d1d3f975fb7da52eef8035e20bd0cd04aab73da8b044889119bbf216ea6171a1
MD5 57ab2337bc840b50874d8efc691078d9
BLAKE2b-256 1618f9fb1c3f7c245649fcf3de2e25cfe8c05493ee1a73063444cbdd57fa3c8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7eda50be5dcf062c3ec264f3cb52088c965ef4a80853afb0abac3b81c220123d
MD5 7e9fdafd4132110f170c684194fd6491
BLAKE2b-256 79d1ad1b0c494fc14cb3f6e8267a12d3740b3a6f9292cbac4c1e644d94894868

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 548d0f297a0f2ed33f39f2045d5127520524dc72899222012c8b69acbd902cc7
MD5 df4593f71494b437cf82120037e7bbb7
BLAKE2b-256 7ab524f7c8a435595a93ae4bfc24fcf364af08c807efac9e3b9414f6d76762d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 733.5 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.7.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bcb995f187850fa5f1737824045bbc1f83c9956764355414be287dbf69879ed3
MD5 126f2f668f778bfdede32c797d4c9b1c
BLAKE2b-256 b1f92ed71083173dc5c947ca40393ddf58abfc6eb8f0bda3270d37ccc19c0a11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0bafcc8980534d44fcb4848ddcf1fc9193289e0c122200f220b83c86aab60218
MD5 bc0f9960eb3494c6b1c9619db87b55fe
BLAKE2b-256 a53ec6848896bffe14e4eaf0a096930f886553498853e08d5ff21037a78ebf05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2b956809c81e022a7dffe94ba1766fd05923bfa0054a29f27c59dec78a97a99
MD5 fa0f0842c264bc31a210520e268993eb
BLAKE2b-256 14babea098aa2188432e7a631ae934233d4878f81f69e9413339e9a32fd28965

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 726.2 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.7.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c0b0965fc543346fc698985517412264128c2bfaa60bd74476fea5423525a760
MD5 959c789b8539fe4e6129c8aec15d4854
BLAKE2b-256 a032feaada288f8c067916ee5d3cf3fb9a6e228bee57fcecadeb5bf7013a540c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7185badc030bdafa773333b0ef14eefd4c10d11fcc131fcc0103b2c38cb3c669
MD5 31eaecf5c92cee382033b59fbe232d95
BLAKE2b-256 326909090777e02add0b99292fb79f9ef6f4f0f289a519f6de93d885d75dae30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4507379ceae6d80e780b903fce32588040af8f5475b47e91940fc3e2f0789b66
MD5 0134dff55bee3d638433b966a8fb615d
BLAKE2b-256 c169b41b271659844ff10e94d4732c6183bce440302e103ae5162f42b0dc6e89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.12-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 726.1 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.7.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3dbf3f13a50e68c3a91461d045269964fcca19138fa282bb581b9177d53f8644
MD5 9ab30519858079da13347ce59ac9edbe
BLAKE2b-256 5207d7aab3024550df52cbc2fdf85e278cc12240b72948b49d1186887fb17c5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be9aebcf93929bd909b37f3a3447bd0fed8db70742ef4e5f8d312474b7e43cbc
MD5 607af9b8c66323f376fc9134f4b0ffc2
BLAKE2b-256 e03d3c4ae99fcdac8a4d0cbbd6972ba8055e2fe269ab0ddf1495f04ba6babb2d

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