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.10.tar.gz (327.8 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.10-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.10-cp314-cp314-win_amd64.whl (752.0 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.10-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.10-cp313-cp313-macosx_11_0_arm64.whl (823.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.10-cp312-cp312-win_amd64.whl (733.4 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.10-cp311-cp311-macosx_11_0_arm64.whl (830.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10.tar.gz
  • Upload date:
  • Size: 327.8 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.10.tar.gz
Algorithm Hash digest
SHA256 b5936f676c96c7b19b3853805a9cd67210bc51971be4923bc4ae39318e2dba72
MD5 3302eca03b67abed9a96e4561e687e12
BLAKE2b-256 7a2798addc8b5a8bbd99b30b189bc60a0512150b00550d19a13e2f5dcced086b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd3992d3fd55ea54853a96f4fc8059741c4a8993fcb27ebf94c503a0473740e5
MD5 e533c0d117ab4eb89b3c637098e16683
BLAKE2b-256 5f7512c88e6c303aabf3a6cfb251e2da38d238900892bf24ab091fb70934eb9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 752.0 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.10-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8c6677fbd7cdd35c83f51f630468a3c08ecd050408a771c60a021e9c57876531
MD5 813172df7656394bc2d50645c1111f28
BLAKE2b-256 82feaf23e292fb012e546db30fed8045c8053ea4445d3f7748efb66ee159b023

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d607a17a1116db039f04925a5eb793db0ec9d462b4fb1464628095c40656dda0
MD5 2141ffae79b68facb38ac295ea983259
BLAKE2b-256 b0c2483698b88fc9e6dd04bca63a2824f0546bdf6262ac1ed2768b48cf1ce9ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e22b0f14b34735fdd951f07443fb844abaf917d440bcbf9cf1f73a53808af70
MD5 ab1525871c329963724abd72d7645740
BLAKE2b-256 a821978df0c2d2424c17e17857cac1a641391d5c139cf75c95849f4471771191

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10-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.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c7a9b0df1da576162010a365b61469582c413914866194b5279a3544e53a2eee
MD5 2a12a8dd44275d71a7a9aaae34112949
BLAKE2b-256 42f8a21bfd122b858abd53c84c0263af12940cc681221496e1d171eb9044a58d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 17ff543842e8e724e0d1256478754a8ca1140bb40f55679478d544a533f8ca34
MD5 49665efe0f49249fe875f362771b85e2
BLAKE2b-256 61c86eea99900dac7cd0760654c6c9bcccbfe5c8ae5765aee6d7ba6d58c22ce7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f8ca011069635748e652e8324b2677c3f45056732c959d875b9d7ce41586d12
MD5 678ebc5ef94f387550e5c9cabc3965bb
BLAKE2b-256 4a9671be0c8126c5fd5574e4206ebbdc2ec4d3f5db56931f37112fe305f06f3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 733.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.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1950447263976e57356b6bda9457b77f07865b98bc95dbfdf38514d480bb2f41
MD5 3a3619931652e2e4ccaea576582fde1f
BLAKE2b-256 d501d209e96834df97546b24b8ebc70d157751af1054a7b5fb28d99fdec218a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c9b01e758fe003cf74ad39bdde33e7b96f3cc764947c0b219551221eab33b05
MD5 3033dfff1dbfbd707519b047dadc4138
BLAKE2b-256 44f03a7150c7ae35fc24d3171f56325ec9de3371852c5ee37669cbb02f1f1502

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7965eacf927b488994dd857542bfbb97872bda44ba6c2420d8d7b4d5dc0c68dd
MD5 c9e4873edb07fbd37653c1e013cb8acb
BLAKE2b-256 da78bf9ce301dd31a7a7211aa4acfce58393299c3cbe6fddfa89ddcf51d473c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10-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.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd5169d0d0ea75c4b6669dbd624419ed51d0bb3700004bb34e53c0534c806dc4
MD5 0fd9ffcf18d8227ffd6ecdb173e219d2
BLAKE2b-256 146b42fad79a978303379ab1753338068a98c7d4fc7566607a681dd63592b2dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a66a25b0238d83ef9433e3c7d3e9a625c9aecb8765b0027397c55d36934089b
MD5 3e75f8a48d0f5e68bffb24e09d435703
BLAKE2b-256 7c7da443df750f9f57b7654141537c3b38b07ec8a8a07184c5203fb2535859d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d20350b2e222ff9c9df6901bf189cb443be3c4a6312a6d78f7d0aba57810549d
MD5 877312b39276018f1bbae356d72189e3
BLAKE2b-256 9cdeb6515c98aaf72dd0329ea51acccbc793de374a946cb9601307d0c5d2161f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.10-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.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2d699af3ac59e2c40e3fbfad466a666e95cd25e8009061f3116453a53baf33c1
MD5 3e0adda0d408b5877350bd50d2c4e0ae
BLAKE2b-256 4786bb0a48414496b80d63bdd9e4ced8e5a1d9d9407b780c4fb218d57e8940ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32420ea994190d8a42582a125d2d2f05b55ec481c64494ab57e992342522a705
MD5 e9171d2ed4dcf1032b5c38608577279b
BLAKE2b-256 19b68e24204f1decde7835f374deb65021631bf9653405a4d703af6765d635a2

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