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.16.tar.gz (338.9 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.16-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (893.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.16-cp314-cp314-win_amd64.whl (759.6 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.16-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (920.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.16-cp314-cp314-macosx_11_0_arm64.whl (848.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.16-cp313-cp313-win_amd64.whl (741.7 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (903.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.16-cp313-cp313-macosx_11_0_arm64.whl (833.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.16-cp312-cp312-win_amd64.whl (740.4 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (902.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.16-cp312-cp312-macosx_11_0_arm64.whl (832.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.16-cp311-cp311-win_amd64.whl (734.3 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (894.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.16-cp311-cp311-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.16-cp310-cp310-win_amd64.whl (734.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (894.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16.tar.gz
  • Upload date:
  • Size: 338.9 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.16.tar.gz
Algorithm Hash digest
SHA256 985be925cabe63652aaf038a4fc1eb074a7ae1653b14862733c5fb3986799a46
MD5 698fd7712e0af42d2b81bf08ddccf101
BLAKE2b-256 eaf30f86a9b3a851dc4d54a52fbc5e96d94c848935520a55d9b32900bf4c4452

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ee4846debb43d6d9bc8e5626f1b51efba0b8d3e76645f0bfd5147ca8b4f69a4
MD5 3cb6a50d7e0904db6aff78e77db695ff
BLAKE2b-256 267b96ea33bffe38e3d1350e03002460950bfb1936a7881bedb32ec370c3a897

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 759.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.16-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 413310a87a827b5c9b70419b2a6ab2e5b7f93a700f7d803cc3955d29d6fb40da
MD5 53bad73b19b348f01519ed92ebc5abf2
BLAKE2b-256 f088a913fd55f2daaffe7b39a91fc090cccfc4924433c722fcdd2c3521d9b2d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a65f4a8d2e5c2ab91d8391f34e0226577fd98c6b175c885e7673030484cc46f
MD5 9595b5c27b35ffa1fdd49592efa50f6f
BLAKE2b-256 59bbe32be97b22ec838ef806e82e2ab4cd2f7c9b3f09327caeb92c151b07f993

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 757b71caa7b76d7392bc4830b0323c0dbedec65dda5046e6a4e1ba9d389a8e51
MD5 e011632bad522d9b4a154c21f8dc90ea
BLAKE2b-256 5c905e62f1a889e8a9e5fa3b8e2e7f0fe693cb2fdb8a4d1b2cac5204e648d0ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 741.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.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3c78fa2fa30d66f94090ca4c951e6b6334cf018158b4c904e8e4e92e45c0a0bf
MD5 dda4c9ebc3a47fd2fe811dd0b74a90a0
BLAKE2b-256 77c6be0179966dccd4e5746d46a89ceebbe53a863cf82d57e15980b8bbde85fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b370462c31adb6b30ccf40d33b6008d010f3154c2a22b0617bd17edbf4d5bba
MD5 cabd0a9dd699e9c7816ac1e5f5b07f00
BLAKE2b-256 deb3c51336d7f1ef53918a67bae0f27b63e7841c1db59b787dd141b7e60c7bfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f26f067b7fd72aa02a1a544d4b4a25197d671ff4adb0b90398b0c4676c2b3d7
MD5 d294b89a87970760b8ae5981d2344f76
BLAKE2b-256 fed78bd8b5d821449fe0047dde94d8288e7a27d6b30b3fc8b1dd6f0627773fb6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 740.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.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 27d1cb9cf23295269593190bd2673fd84091a2e77c57cb840748fd2992c4ca6f
MD5 cba1d7aa9f6302cfb1dd2055e24b596a
BLAKE2b-256 9e414681e780d1d63e59b32b3b7af4615b58fd1db698c35a16ac6fb80f9bb6a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c1d561780e51f7ae8f25772d803b9432aefd144dfe63a2f0d786c8eb019ecfa
MD5 2bd59eb289717553c161afe65722ad05
BLAKE2b-256 8c16351bb97df1e63715db8bdaf27e80b6922d21e61600560ced11560847e8f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76b3ef44423e87c11678db99cae714d27a6cf31bc8f0e9947c2a0cc1780aa842
MD5 3e900e6ee5775f22649bfabcbb7d0e78
BLAKE2b-256 60dd608f125a2f812648d9cd0161995d50bd5b764032fd58902de6c6671ca3d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 734.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.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f59d0f04d72d9e2f40a53b1c8ee7616f7cc57ee03e528507e5c23e2857dbed91
MD5 0cea81a10ee7a083303040844a809161
BLAKE2b-256 e135c334d465e94ee9c68a61e242161b53ad63265564c18cf8f64b4481c53e65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fa95c9ae33ca73914dc193edb0bbc7b7d00cb51e97421654a673f3908942c1da
MD5 fd95c89829bf92f45e83193ec3531968
BLAKE2b-256 b267bf350316f87735fd6a0aeee656eead368fef86b9399189e4ce7efc9f91d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9296b01c7c3a17766291533ddd74ddc7c6287de4b327182a7ab25e9c257133f
MD5 cdb0c1f6416594382b984395dca20171
BLAKE2b-256 b52b2dc2c1cfde55edb2ae91112c0575b31bda95c9a7b6e29f01896aabb0f4ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.16-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 734.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.7.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 091b81a84d2b995cb69cb52336f9c6e2798a77727d4e0a6a0d14d855dafc7282
MD5 09932566422916efad0601a79ae1b1ff
BLAKE2b-256 bd5daa2e2c39feed8f7cd6395849490b26e60c4004363ea62cd3a2576e677d47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c2155fd2d076734223c45d2a9da595f9caf6c1bb56a0dd6dd16eb5309f9ae7e1
MD5 d98aa919b5e3c2ccb11a157218e6b3e4
BLAKE2b-256 d4150c7bc9606572167556e7bec9bbbee456b4d435f00904e3c2c4aff2d473ee

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