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.14.tar.gz (330.5 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.14-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (889.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.14-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.14-cp314-cp314-macosx_11_0_arm64.whl (843.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.14-cp313-cp313-win_amd64.whl (734.0 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.14-cp313-cp313-macosx_11_0_arm64.whl (824.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.14-cp312-cp312-win_amd64.whl (733.1 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (896.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.14-cp312-cp312-macosx_11_0_arm64.whl (823.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.14-cp311-cp311-win_amd64.whl (726.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.14-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.14-cp311-cp311-macosx_11_0_arm64.whl (832.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.14-cp310-cp310-win_amd64.whl (726.0 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14.tar.gz
  • Upload date:
  • Size: 330.5 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.14.tar.gz
Algorithm Hash digest
SHA256 194c216567aa6087ef8ab8e3fbea75c76c6dd5b3aedb41a446b7a4d43d64ffce
MD5 ad3c7934bd1a95b98b25d51bb8f98bd7
BLAKE2b-256 b5a9ab1c356cb6cdc72a19f047a50b52bb73e793993a7e66fa782a8b3ad3f656

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb948b574f5cd3ff5d634823abae99cfb2ad22b1775e49e3df726a0bd5c2092a
MD5 7312dc61e1d4f7744da84fc928904dab
BLAKE2b-256 64f66f92770ed408856b729a31e4fa8cd2acb054cd55c577b24ebfa230dbc49d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14-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.14-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 21e89e3239f62bfd11df9bcc2f70a55c17c34fdec8946c901067996f19e347cd
MD5 4cdeb1c9941311921199cc819378eaf3
BLAKE2b-256 57b7adb6bf77b0cec296bc0011c06410cbece1e7552463580258f43cebdd2f53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6917203e33477ea8b8e68b59423a2e9044a23f28f69b05a24095989d4a751d16
MD5 36b7f60fee38a0965780f74833e27abd
BLAKE2b-256 00265e35cfbc10d03b6f88b275eb0d231de9542ba9e6749b80af7860dba1281b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7b3a469838a71a9e3018b11630f803ed0d8dce784ea0cd4d04c17d7c2992657
MD5 8ed825991c203758da0957e8539433ac
BLAKE2b-256 3594b9768073830484a08ab0de010a344aa22278be6f7e0434b5eb4b87cc2cf7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 734.0 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.14-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 33edff98401c10e2a992afcd7fddeb070cd3faa1450c6501f9d47777b73f73b8
MD5 46b6afe3802f4ad14c5d6b20c0df6b94
BLAKE2b-256 e9d58e560d53cb4d45c42743b26e28c1fd45c5ace0963eaf4af6ae48c18d2f3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aaa2d8864417608481f5c47ea86912fbc7417989ebac8367de2aa4406a6e97c0
MD5 673c2d9a1a81aae620d0ea79712ebcb3
BLAKE2b-256 da783a9c7f05d1e75fad66ad72e0360f6ffd4a0a531c95fe94f8babc2ebaadd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9374156c241678a9e49fea28473184db7df215ffb7983e495d552fdc20e34f0
MD5 5859e15160bcdfc24cbdb7d3ec6cf893
BLAKE2b-256 938c3b5303f265bfb20805bb9a3a5c725d47f63904e76ad260b08ae28204c881

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 733.1 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.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fff8328cbebaf3865396ce55ed7475070a0bac210d619192b0a454a82ba94342
MD5 909c8c4ba3f616ffe3e45c9e4eb57cff
BLAKE2b-256 8a02224cce4cdf3dd675084fadb015bc365daf2bdf501421bc0188d393099805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3190fa2800922aa7e091e777173a05f65cfb83f96bbb5a59e76202af458e8e35
MD5 8fe28e0fe025a6af0fac4567c46badd9
BLAKE2b-256 83a9bb5c51b73b681781f03b9f67ad20ff96bd1bcb8f6df86239b7e6e07e8666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce2f9921b941daef7162412fe241b85199f68b5c8c97d71107a16c09d07b2b13
MD5 17239a0a90313767c0e2c1178321ef24
BLAKE2b-256 5f1829edfcbe8c9d93c29dfff7768fe2c87dd2b582d5a23251316e6f0d5690b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 726.1 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.14-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e832f3cda84c213c2a3827c91893b7568d29d1ebb6829f4604651ae5eb623e40
MD5 a18b23d250569cf8cbd9477a2d19ada5
BLAKE2b-256 46682b73251b6603cbb1dd898058c8fc0fcf8280419ac52d8835f355623676da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64a808010112bc63bd1594ff365820df0c4c7a1139e45bf01f647524ee3fc403
MD5 8d2f36c71ca462f9678bd45477053a50
BLAKE2b-256 ed91132f1bd3bb614824c3c2facafc24c796ba9e7942637a25250713084fca5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30f49dc8a6cb4d5d08e7e1903fe36ab680d66aabd5197bde06a22ddfc4e0c4a3
MD5 d322e41e56d6e8f22a11def5d7841331
BLAKE2b-256 26a8eb5c2203cdde219517769bff2b45c010ac584293ed9d5e38134438e2af96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.14-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 726.0 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.14-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 16d147c98e6000cc39c549fd49687f0a0fd79403015d6dc7ff8508ce6bdca329
MD5 fb771fb8f6b09a55e5ef077bb4fd7877
BLAKE2b-256 ffaa92488a4c8e5437ca0cf0b0e11e510d33bb97db7439e64201eb7c871dd417

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c54945f7fa43e62458193ca35a9ab476290a735a6fb9c6d750c7c5eecec0f1a
MD5 43d4ffc97e806ccb1cf0507adb076729
BLAKE2b-256 1c1ed8ee8e19ad30767ee55f7a2c9ed35f7913cdd05684e98d8721cc9b4c7b79

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