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.15.tar.gz (333.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.7.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.15-cp314-cp314-win_amd64.whl (750.9 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (916.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.15-cp314-cp314-macosx_11_0_arm64.whl (842.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.15-cp313-cp313-win_amd64.whl (733.7 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (899.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.15-cp313-cp313-macosx_11_0_arm64.whl (822.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.15-cp312-cp312-win_amd64.whl (732.4 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.15-cp312-cp312-macosx_11_0_arm64.whl (821.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.15-cp311-cp311-win_amd64.whl (725.3 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.15-cp311-cp311-macosx_11_0_arm64.whl (830.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.15-cp310-cp310-win_amd64.whl (725.2 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15.tar.gz
  • Upload date:
  • Size: 333.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.7.15.tar.gz
Algorithm Hash digest
SHA256 962f5d2f6306e92c77fa09a10d9d9b8f1bbba2e4de111dad958a02f8cda19c76
MD5 870a862a5cf1ffb16b8861998ae960e1
BLAKE2b-256 e6356fd64dd4b49d5630593edb16c5ac1922582a09851ef1a76dd97de001da29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 683db21aec2a9de02ddaee473a7d77a21c8e8dc387fe5544f84322a370f72213
MD5 1087d1855434501b6500decb0676947b
BLAKE2b-256 7b2fbfeb76abf6376a60aa8d529930b0051bc9734f087ba3fa52a8639e9995e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 750.9 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.15-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 48e2e9ab6ca87b9cbdf0fbb0b89aea4f2ca3415dad8fcfdfb49a91a45ba631d6
MD5 8a49a4441b9db2c9a8fe5fece68e15b0
BLAKE2b-256 f5b1deddd4b7aa9fd3b21705ab8b92163539d131159e90815f5ca60dbe17c11d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bd2d004a411dbfef783afebcad8de93142a94c26797b89008102748c8bfe103
MD5 55984449789839561bcd46b48a2286f7
BLAKE2b-256 e0b5f3d4fb4ff07419f433a9bf75a436dfea95f329b553f8951df83aa556e538

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee035b277c86933781fd6cb7aa02fba5ee79d4c977bc6abf65e6675e3638b0be
MD5 9b40f55791ed2dc2621159a9bca0eaba
BLAKE2b-256 40dbdddfbf40d47d9919790bb00776deea7f7e8181d30e77ebbcb4844f4e78b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 733.7 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.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 896470a0027b70c021137d7354997a127dfc2d9a17cebbd8d1c6b887f4af1239
MD5 715d80c89a646b83c1b47298538f2cf8
BLAKE2b-256 4974b2c3a5d35de16fce211583ed3fc73b4f675e196fcf33fc43f08f9a0d65cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7937cdb999aed6e30fe1798f1224ef0c6490577f7efdff18291bfa0257d79557
MD5 4630f6c7738d555d179850611fd86d66
BLAKE2b-256 f9166ddc785c7c1b496072658aec49dbb2f242aa6100756c80b9c810e4277f32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6de5ed1e2df221a86044f0a4574fc9659a3d79dc299f33fec4b859f5933a0d76
MD5 8a927b321ddfe33502555128c73b78d4
BLAKE2b-256 2f60f8959dd6eeddb14b58d54f21d4f003fd9a196f82cb4c0afded6c79bd9f16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 732.4 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.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 902e8e0c7eca1c6d880e6cf44c1dd069c7942e2800eec227d067283d3c7c8714
MD5 08644adf9f67c453fe65915f34e4bc3d
BLAKE2b-256 507a52f4dd180a3ff66d2b3ef52874655d4cec3d9f8fcd62cd35832c3aa84c58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5040cc49e3b7815f0222b918f4b9b2b80f7e04e7a50c07a646ed716ffe5a9f0a
MD5 5b097aa91513b7bf4ad6b1ae8cbc698c
BLAKE2b-256 314e697e4cd15a54984a490767e2c1c430ea18a2ae11d5822dd72da50a8d8882

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7b1e2bbd609f0ac1ff99d8e4b052ecdec6da9c8208a032c90e3300c53518642
MD5 bd98921feecd4acfb92ef5c6eb4e51e2
BLAKE2b-256 750abd0804f790658b300acf1be264c0eed42543ff33e97e3b67b14e6fb6b2d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 725.3 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.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4f609c7a818e11051587819f1905f7cf10fe3abc5873beefe393ef07bf5546f3
MD5 69de85e13ff00d8dcdca7b23bae4b11f
BLAKE2b-256 dadf7901f70d43fdd24d57cd6ca034de364d1764e97341a500f5eb527bbb755a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9768ddc2f37d327fac3df17304de12c4e5edba847a4e8f6d2e78f2f6d14989e6
MD5 6935360ae31b0a5d982ec05e3ec96163
BLAKE2b-256 6304873a81c412104faefaca4987bd20b749f3a509d723aee663162f23812916

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 277fe5ffd688f1bd991674e9ba4dc3d9d6888e666264801b46e718458f04324b
MD5 590feeb7dabe120b5d3f1210cd3e36d5
BLAKE2b-256 f75c60a688b3f52701714494b974a0c336bb3f3babea39301d46f22437486f71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.15-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 725.2 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.15-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 be19ac18117c5512e600023ec529df62972caccaabdf64ac6b3c3cb3f3317d39
MD5 f68f927a4cc66e5c9cbf1aabeb2a1b0b
BLAKE2b-256 f0d30431cf5aea2122d11c74c2077e59398ddf7b1b5a71139484206078ddd5b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1790e029516c9c27142289fc386b9c9a74c680caf8c73ee86f859c73e9409a9b
MD5 3e74aaa08d771798619170466f5fac87
BLAKE2b-256 79311996d496559517f241754c407540746d5124d7baff66bcb3397e39ea0133

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