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.18.tar.gz (342.7 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.18-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (901.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.18-cp314-cp314-win_amd64.whl (765.6 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.18-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (928.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.18-cp314-cp314-macosx_11_0_arm64.whl (848.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.18-cp313-cp313-win_amd64.whl (748.4 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (910.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.18-cp313-cp313-macosx_11_0_arm64.whl (834.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.18-cp312-cp312-win_amd64.whl (747.6 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.18-cp312-cp312-macosx_11_0_arm64.whl (833.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.18-cp311-cp311-win_amd64.whl (739.4 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (903.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.18-cp311-cp311-macosx_11_0_arm64.whl (838.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.18-cp310-cp310-win_amd64.whl (739.4 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (903.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18.tar.gz
  • Upload date:
  • Size: 342.7 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.18.tar.gz
Algorithm Hash digest
SHA256 2f91d290245a0490ada2ee5ccdcf06b21023b86f56096f0ffdf764c6703949c8
MD5 fc3501146aac80e31a94a6de17d866e6
BLAKE2b-256 48b82dae300d7da1331416ceb5edde7c1678ca5ece267db49d7a75e2a92adff4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4124ddf3f20178c4dfadd0ddd114d48e93d5d5ed7718f17882afd795d677ed59
MD5 56fea0e73e84673471a6b73cca59c816
BLAKE2b-256 6005e035fcea2e0d553e1320a3df9c88c63fb88c7f5c15c7dae715c0dd0d7399

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 765.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.18-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 48ebfeb45b9b60db66a5d793a43b4a84c17d7d89fc486bbe72965bd8097c86e2
MD5 8d407b4df3a02e2cf79f4174f235ae1d
BLAKE2b-256 edae6912b8bd46f1e2a8c6330120dfc3737961f03ca6cae9a1ebd113e9db268c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e26598405f854aaaaaa8fee5ad74ac5e7d3c16d22834ddc680e00d971d6b94b
MD5 631e756808acf673b3ff111e9bcabc88
BLAKE2b-256 94eb4a59da31690008c6a94c7a2cf854c47d5943aaa9a3f476c62c43dcd424e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c7093851beb9444f3b42e89e45de3cd513a0c2190e7eb1a7604cf4e1aa26857
MD5 78932b34c0e15ecc58f2d076ee9c4575
BLAKE2b-256 c0f4f70823963aee3dc56f5e405861eb559c8374fa705af2f9fbcae1482ff4d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 748.4 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.18-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6123b0cfaf49558778d84b5183eebf7bc13dde4bf1ef8d04cc7b3e9c41512e2d
MD5 356da3f4edeba3290675e19615a74b39
BLAKE2b-256 13c9afe81507454309dcba6334637028fe6ad9802632579db93f4b178b48a06c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 059084504da56ce1b0bde1ef1630fb1aef96c4226e6fa63ba36eba44a4d9007a
MD5 d1ee859e050c7d0a20e1ea1e3886e4a6
BLAKE2b-256 4c07b83f9e5e1d55c067ce764db90ef46df26aa4764ffdac9a50f065b2e1a932

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c43ce5f271382a22b9d7fc83edecb2321c9808a97599ef181a19d7b1625a7a8
MD5 906f4ed8136d2a364ebd3b6ce7c64e56
BLAKE2b-256 f810865a16e9ccda8beda0705c358842fa550140b6577908475e278f8f2c6aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 747.6 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.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9955327f6b3dfeace63b2e2e2132ec5e77ef34b85d55c081502b1e2d68fdaf53
MD5 f360eec8a44388833c53c07f5873ff68
BLAKE2b-256 3d194abcd7a8e77a5a4e0dd21b2501a96e849af343f6e4f3af96bf2f16630e8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 170d671592c2dc61635c61e64a7b388aa4e22649ae5758027aa312d57c3ad728
MD5 5293f733e4f7bfb890f0dcd7f951e7c7
BLAKE2b-256 384e55754fdc7bc45691292851afec93ba18ae419503b4be27bf46196b4338d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2807a3c8409fbf1a9b4f057748f5227830c25c358fb59c8ffa6209b27cac7a86
MD5 78226bd7e99b06c064df1438af43c571
BLAKE2b-256 cf025d998720973afde3400cc4472378d2786e2909da92514c96b3bb76c2185e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 739.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.7.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d2a64a09153d0aaf2fdd87d8c2d31a9db9ca98780dab86000b730b6bd0d01a49
MD5 dca20960246104307f30dc3c03a7de8e
BLAKE2b-256 543fef5d059fcf7d6d073929e6d9173aa8ec4243a3c3aed7fd94f45a879269ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d92a08bcb87772a8dc443b3a070f081a4d801cdcd59c580dfd81340d68568169
MD5 2e4581b3b1dfce17efcee9bb9d60c1bc
BLAKE2b-256 2e4c8bc7f143ab4e61d2231c0ba953a8014cedec954b42a08673673baaeb850c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ddb81e5fc718c4662d5a1c88e71c25f9a5facf7cbf387dbff78a1c14e459fa8
MD5 47c782d51d4985c1b3e978c500574886
BLAKE2b-256 9a483f19121018316cde1aa49cea326e5aaecb25dee58d445c7fd41babdd47b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.18-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.4 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.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cc40aaa0f288ae956a872835eaf2651c1338a29bcfa1ecc44399e66c05705392
MD5 54a8ebf3de0c4a26e64c9a71c7af3b0e
BLAKE2b-256 5cc52340791dac6f778dd835d9e260ba2c624df3d9dc86bc0063fe9fb5a86ebf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d64b931c676a6720f35efbe84a6bf78571c6ed66c5867a9801d0ef56ea584c56
MD5 b935546149dbd205da410d03057e477e
BLAKE2b-256 7976b20b60d976df6928b08033cd8dd70646bfda19890d7beeccf3627fb1d535

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