Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Reason given by maintainers: Project renamed to rsshogi. Use rsshogi instead.

rshogi-py

rshogi-py は、Python から将棋の局面・指し手・合法性・棋譜・学習データ形式を扱うための ライブラリです。

English: rshogi-py provides Python tools for shogi board handling, move legality, game records, policy labels, and dataset formats.

Rust 製の rshogi core を内部で利用していますが、通常の Python モジュールとして使えるように 構成しています。通常はこの標準ビルドを利用してください。AVX2 対応の x86_64 CPU で AVX2 最適化版を使いたい場合は rshogi-py-avx2 を利用します。

Python API は cshogi から影響を受けています。

できること

  • SFEN / USI から局面を構築し、指し手を適用して更新する
  • 指し手の生成・検証を行い、局面を SFEN として出力する
  • KIF / KI2 / CSA / JKF / SFEN などの棋譜形式を読み書きする
  • policy label や学習データ向けに指し手・局面を変換する
  • データセット向けに NumPy と扱いやすい packed position 形式を利用する

開発用インストール

python -m pip install maturin
maturin develop -m crates/rshogi-py/pyproject.toml

AVX2 ビルド

rshogi-py-avx2 は、AVX2 対応 x86_64 CPU 向けに最適化した同じ Python モジュールです。

python -m pip install rshogi-py-avx2

注意

  • rshogi-py と rshogi-py-avx2 は同時にインストールせず、どちらか一方だけを利用してください。
  • 幅広い環境では rshogi-py が安全な標準選択です。
  • 学習向けの policy label 変換は rshogi.policy から利用できます。

Policy Label

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

クイック例

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"

構造化 import

rshogi-py は用途別の submodule から import できます。

# 型と定数
from rshogi.types import Color, PieceType, Square
from rshogi.core import Move, Move32

# 盤面
from rshogi.core import Board, PositionState, ValidationIssue, ValidationReport

# 棋譜
from rshogi.record import Record, RecordMetadata, GameResult

# 棋譜変換
record = Record.from_kif_str(kif_text)
kif_text = record.to_kif()

# 棋譜ファイル I/O
record = Record.from_kif_file("example.kif")
record.write_kif("example_out.kif")

# NumPy dtype
from rshogi.numpy import (
    PackedSfen,
    PackedSfenValue,
    HuffmanCodedPos,
    HuffmanCodedPosAndEval,
)

# Policy label
from rshogi.policy import move_label, compact_move_label

基本的には submodule から import してください。

from rshogi.core import Board
from rshogi.core import Move
from rshogi.record import Record

棋譜 I/O の注意

Record の棋譜 I/O は、内部の rshogi 実装と同じ互換方針で動作します。

  • KIF/KI2 は ShogiHome/tsshogi 系の実務互換と shogi-validator 寄りの整形を意識しています。
  • 変化手順と終局要約が同居する場合、to_kif() / to_ki2() は 変化:... を先に、 まで... を最後に出力します。
  • from_kif_str() / from_ki2_str() で読んだ初手前コメントは Record.initial_comment に保持され、to_kif() / to_ki2() で 1 手目の前に戻ります。
  • from_csa_str() / from_csa_file() は CSA 3.0 に合わせて '*comment だけを プログラムが読むコメントとして受理し、plain な 'comment は読み飛ばします。 受理した開始局面コメントは Record.initial_comment に保持されます。
  • 互換性のため、手番行より前にある '*comment も initial_comment に正規化して受理します。
  • RecordMetadata.comment は自由コメントではなく、KIF の 備考 / CSA の $NOTE / JKF header の 備考 に対応します。
  • to_csa() は move comment と初期局面コメントを '*comment として出力し、 write_kif() / write_ki2() / write_csa() は末尾改行つきで書き出します。

Metadata

Release files for rshogi-py 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rshogi-py 0.11.0
File Size Uploaded Provenance Actions
rshogi_py-0.11.0.tar.gz 451.1 kB Without provenance Details for rshogi_py-0.11.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rshogi-py 0.11.0
File Actions
rshogi_py-0.11.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.11 PyPy 3.11 7.3 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for rshogi_py-0.11.0-cp314-cp314-win_amd64.whl
rshogi_py-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for rshogi_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
rshogi_py-0.11.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for rshogi_py-0.11.0-cp313-cp313-win_amd64.whl
rshogi_py-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for rshogi_py-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
rshogi_py-0.11.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for rshogi_py-0.11.0-cp312-cp312-win_amd64.whl
rshogi_py-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for rshogi_py-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
rshogi_py-0.11.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for rshogi_py-0.11.0-cp311-cp311-win_amd64.whl
rshogi_py-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rshogi_py-0.11.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for rshogi_py-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
rshogi_py-0.11.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for rshogi_py-0.11.0-cp310-cp310-win_amd64.whl
rshogi_py-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for rshogi_py-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 17.3 MB

Release files / rshogi_py-0.11.0.tar.gz

Download URL rshogi_py-0.11.0.tar.gz
Size 451.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dfc93fb6b2891c365ebf83be833e2c0cfae3265082cfdda8c3589b6c2e5c66f8
BLAKE2b-256 checksum
How to use checksums
2797e415dd7badee6a9d36c84dd5d37fb4b373189bda676b8c4e3bc5efdf8389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3
SHA-256 checksum
How to use checksums
100a1e7b603497759c7df004431f2d5c6b8612179bd88ddc5559e8181ebb34d2
BLAKE2b-256 checksum
How to use checksums
f9973a1f2ea00925c1c54892ebe34abfdd6183367bac1f0a567e266e208b060f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2a4a1bf2df35d829d506829255040673ab88467e79e1b62195a60be2cb48cee9
BLAKE2b-256 checksum
How to use checksums
2ea3c30d390a931642738f10357478414a54eb13d694a61cd9b1c25581352896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp314-cp314-win_amd64.whl

Download URL rshogi_py-0.11.0-cp314-cp314-win_amd64.whl
Size 1.0 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
2e70ed36aabf696d82b28c724b7db0e84f5559d298b7624109f391ccb6bb1f81
BLAKE2b-256 checksum
How to use checksums
f6c97c25986f3829d572a90456b5622c801dc669364359b1b505b1f10b915801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
eb7688c56a7acd9fe5f8dc18f01737c516946cd998dfa7a2c075ab80d7a8af29
BLAKE2b-256 checksum
How to use checksums
3fe6b2b40e1e1d0940306949e92042757b3d28a024f35ceb5b44630663cc4627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL rshogi_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0a1b6857daf6f5ee1ccab3f515ee1d4683f4d9631a5f4c9bf3285f5f66bdbcac
BLAKE2b-256 checksum
How to use checksums
f927917320607f7469d2fddf052965c11f5a1c311453ecbca01bda5f765d74ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp313-cp313-win_amd64.whl

Download URL rshogi_py-0.11.0-cp313-cp313-win_amd64.whl
Size 1.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3bbdf6d7dddc97213656f269e2ed651fd6a41facb00d805e75565bbb111b3fbd
BLAKE2b-256 checksum
How to use checksums
cc5a9f214a59a056ea18fa401b7b8354346c665cbacd083869d471af8aa362c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b525d3a5f5ecda8f3d58a699ffa009618f329c2f49ab4cf9ea8f236ec263c991
BLAKE2b-256 checksum
How to use checksums
b51654e9ee14182a0ca484fce814fb47259ed84d376a4edd8520fc9a37675502
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL rshogi_py-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
Size 993.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
556084830f7d62207cb87c7c6da0aecd80376c4133e71622e752e731da9f0d24
BLAKE2b-256 checksum
How to use checksums
08f42059facc57a80c9ef49d6f7b3e07bec785bd5670f5ceb54ba0eb9c59c247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp312-cp312-win_amd64.whl

Download URL rshogi_py-0.11.0-cp312-cp312-win_amd64.whl
Size 1.0 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
8954785260f797ad4b1ad55d4df62f6394b2833078977473838de59a9ec7bc21
BLAKE2b-256 checksum
How to use checksums
445752365d25cf75c17e86f0627caf809913d7fc6c34bb85e738e7d1346b720a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
638a3b607de4debdb75432543fc16aeff977298284d8f74c669e8b11d9584483
BLAKE2b-256 checksum
How to use checksums
63e5548ba2580d47f6199b30650744953e1662d663c2c32c0ba1dd475abe266f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL rshogi_py-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Size 992.2 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2e2c3224e8e4e026d6649e3a875fd68293ab6e093d9b9be80e8a0fbaf0a000fc
BLAKE2b-256 checksum
How to use checksums
f4f7797432bb019d11a8c19d6d3b237799e22e805512f59ea59c17c350fd720b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp311-cp311-win_amd64.whl

Download URL rshogi_py-0.11.0-cp311-cp311-win_amd64.whl
Size 998.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
3b2cc6423421fd911153e1bf93b3562715c23b55415bcb0c6cd029fb37021a21
BLAKE2b-256 checksum
How to use checksums
4ab2d6801a27708b0872d8ed3e3713dea88c92a2e3f14ecfd6c577fcf2497a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f3e4d72a7dbefa702f309a74b12b1206a07ee31a634cd3973835616c5756ce04
BLAKE2b-256 checksum
How to use checksums
f49c3affebb8ce7f9f09d9e5765936749a14c69a32dee6fd3376775721c98d68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL rshogi_py-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Size 997.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4f248dee6566827fa12ef73b8def14d60ffd09379a2a8874ae7380099fa5909b
BLAKE2b-256 checksum
How to use checksums
eb4c1a6c13d5a0cef9e46c4ded71e37fbb4b3979d9d4f6c8b160328cc0c51815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp310-cp310-win_amd64.whl

Download URL rshogi_py-0.11.0-cp310-cp310-win_amd64.whl
Size 998.7 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
829f4cbfb36693b2ad3bfa4f829a3d6f5120b7aa56021216f65fcc1bf1a40791
BLAKE2b-256 checksum
How to use checksums
700ceb031ba29512acc84cd9aaf9284046a98d5bd66679abcf03ddd16a9dfad8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / rshogi_py-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rshogi_py-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b7b617066fe16ba855e107e7dc642b6f738c33281618126b45e7d40212829017
BLAKE2b-256 checksum
How to use checksums
c52946c9ec46faa92e1dc6e2e794d71e58e24d21a0126c87e3baf862a033f82d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for rshogi-py 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11.0 This release

17 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page