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.13.tar.gz (329.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.13-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.3 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.13-cp314-cp314-win_amd64.whl (751.9 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.13-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (917.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.13-cp314-cp314-macosx_11_0_arm64.whl (843.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.13-cp313-cp313-win_amd64.whl (734.8 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (900.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.13-cp313-cp313-macosx_11_0_arm64.whl (823.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.13-cp312-cp312-win_amd64.whl (733.9 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (899.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.13-cp312-cp312-macosx_11_0_arm64.whl (822.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.13-cp311-cp311-win_amd64.whl (726.6 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.13-cp310-cp310-win_amd64.whl (726.6 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (892.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13.tar.gz
  • Upload date:
  • Size: 329.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.13.tar.gz
Algorithm Hash digest
SHA256 09032e5ac53e6976caf7db61e167bfaead556c2e21f8a73cb3384bbdcf61b042
MD5 d34d530c2718335747ac16e8c51e4bea
BLAKE2b-256 4f868d07a1081edc3125b1b3266492a289f2380089aceae50ece115cc68398f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e68db6bc149502a646a2f252a238b425b0da433173cefe49908069da47761de6
MD5 a76a30ca5204309a9dc8e7d4518f8aa4
BLAKE2b-256 a4abd3a8c73d2c289335ffe3d0c39a0c4fb487a044a3f87ec7f18b785253d3b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 751.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.13-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6356f3ef300b4c782c8bce60807664c37c4b86d936751f823513a5ff4a5c832c
MD5 033cc77726bf60406631769e56c690be
BLAKE2b-256 24f3adaf9589437d50e62e5b6e9eac950cc5955ea0640c613f9a6421c8b66a2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eaeee602e37221951cff10a934e406968433cf14e7ba8a077b7b6337367d8816
MD5 129f92811292bba641100b0cdff421e3
BLAKE2b-256 ed35bea5b4236cc4abb077a1623ee52e8f953dda7c58378a4a5bd917571f01fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9844fd5a3ad8ba006dc839031f56750ff4a03fac1af05de73e2f7d2be27595a0
MD5 ec5a3b1ba411951a465d153071995fd3
BLAKE2b-256 80cf6183e682781d2a3d2a20749aa459df46b9574b5080e79d83a35feefe075e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 734.8 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.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ac66c544aae8d11130771438903427ab6341f87bb6aa70b08a60091df2929f87
MD5 ffb4d138b0058a5afa5c04e8a211f0d3
BLAKE2b-256 0fb22cfcf430a3cbcff5b940cc3eda140fba1f3c3a7bba77a0bfee56b2ad23a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 75ec7b106d15f35c795af03bd07c00be515a6d83c8accc8791eab45c595addef
MD5 6f9834981fe5e15ad7af808ec014387d
BLAKE2b-256 498e29e4d869f2d5d80aae04386aa4f3d9c0559d3f44254837806d026727297d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c41a2bbceeb4a2c85e11e45ba05e1608e584676f1c97be38482fa522e95e3d7c
MD5 77e2edf66742f60169f8a63d06975cd1
BLAKE2b-256 4b4e1e5996c8c3c150b2daeff5cf2a26d6f7d5d4d035ffd0ce03cf553f84ca9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 733.9 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.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81f5cbe24e629034e64e3e71f25400a77661a4205b14a7e8a38402bd896dad58
MD5 e2c037a55926401dc2be1cfda2f63cfe
BLAKE2b-256 2f9052752e01a403da29072b83d6870ab75c927578d628c2115178e2849fd3c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a85864f813d619af8c21c74040fcbb27dbc8472275455851d570c7ea5e9b6d11
MD5 6e19129cf790c640aee52330312efb87
BLAKE2b-256 a5ae2e041d71a61c232ba0d511bfbb8e666c69e083881e1340ebc942fc9ad752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b6b692a4af6441192197585c57cf680c476af694847816308cdd3b31720b028
MD5 4143294d0bc03cfd787a907f5808884f
BLAKE2b-256 5d6cca010311668b3c9f0e2aa1cea4de217dc02d7e774e14f1ccea1669f264d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 726.6 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.13-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 028f1ae08b1d91ee352fc8754e33bc6233641e796d2b013603d1ccee0e19bd61
MD5 d6892e9976a94d8d9237a6739a3d563c
BLAKE2b-256 1459fdd4a39922a0c46b9fd921d094da42b78042c2f55d0ea26bce50414aa855

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d184e956116950e2a04ed86aa118c60e4b608f0ff81d5bcdd28f62e1f1abb6bb
MD5 8a5e29f4d2e0fdd1e63e8682eb225fdd
BLAKE2b-256 4f90fc49a004d422665b0be6cfc20902e0bdfc8452c5de4aa0666f35663a592f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9510fb9d9f8cc5f7dc13b09bb1f123cc2ace0d3ad360a9e6f73e2bf4287dfe30
MD5 64aa68b3b1be090dc4732d16960ab564
BLAKE2b-256 799be773da476aff8d24992ea41a7d95ec84935f9579fdcb83d7e1ae84b90bae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.13-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 726.6 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.13-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c4cdbf0896fb992f9c90aa93afe01f6a809bbaede3e379d21752653c729e2fa
MD5 c135f15863d6fe94ddf2ccbb8cd2f8e9
BLAKE2b-256 3f3f4470c998679ff3f431da1b4a075613e78be7339a75b2fd9cf3290008eca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 41aec84abc073c27ccd082a48ead6abb669ec114baf4bb990c1eaf243be5c851
MD5 2b74f5e3048b6a0ff6394773301e7e13
BLAKE2b-256 a896612776df4e668d28bc903bcec994015099bbd741d05f939081a987893736

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