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. Use this package by default. If you have an AVX2-capable x86_64 CPU and want the 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 for AVX2-capable x86_64 CPUs.

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.10.1.tar.gz (350.6 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.10.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (867.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.10.1-cp314-cp314-win_amd64.whl (793.7 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.10.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.1-cp314-cp314-macosx_11_0_arm64.whl (810.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.10.1-cp313-cp313-win_amd64.whl (773.9 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.1-cp313-cp313-macosx_11_0_arm64.whl (793.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.10.1-cp312-cp312-win_amd64.whl (773.1 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (876.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.1-cp312-cp312-macosx_11_0_arm64.whl (792.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.10.1-cp311-cp311-win_amd64.whl (766.4 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (869.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.1-cp311-cp311-macosx_11_0_arm64.whl (798.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.10.1-cp310-cp310-win_amd64.whl (766.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (870.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1.tar.gz
  • Upload date:
  • Size: 350.6 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.10.1.tar.gz
Algorithm Hash digest
SHA256 a24f5c3550f10803b931fd33780fbfabaf41ff202d3b9eaea3e1c065f95b26d8
MD5 eb3ec7d60970ea21d032bc9752656634
BLAKE2b-256 cd3448fa938f854341aaa0bb330fd3f126be05a86f221206c10ff13fd81ff87c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28483c89ce7a9d421daf3d4fa7a1a33da4f923bb026386f6073b952acf8c909f
MD5 1a119a28ccee97ef8c6a38bef9891351
BLAKE2b-256 fc26eac32e5ccd62e2c568e47c5dcd1f161301bdf3dadc3817434248f5880ea8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 793.7 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.10.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2a416bb52f148faa0bdf5a59935694d5f58af54d73b9e4fe8dc462c903f2c669
MD5 fc4c75a01e5471b0a928bbbd9d460972
BLAKE2b-256 13b48a29e7c7be80ba89bf5a213307f19bdda7325788662e260dcfd602d9b9de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c95e8ccdc9d52750afb09a05d1044ba5d527390fc55a3a643d87e55419f0ad1
MD5 8372e9e1eafc6b068419493370437832
BLAKE2b-256 1bc55dbcb8c2289c5f41235f2f207959237164752f0697a88a80888a403feb45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d904b32a91fe25e53dc5ef8157e22cbe3cc2f0c742b9147bf526f0e5193fd8d3
MD5 69933901e7208aac0d94f5e2abc1713b
BLAKE2b-256 84a36b0a803791aaa9c238e61c238efea9226c73c79f27b049208bc60712e578

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 773.9 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.10.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 07a12384c9c1679286867c1c34f36cf41fe48a0125fb744cb46479283eb13638
MD5 e2a2bc69886ef78e75ca705b27b04094
BLAKE2b-256 6c2f5a5f5a0300c8e0690b979af6ec3351817fae1782698b7f08dddafad403ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b729f976e0b940c102183a296678daea47e3d43c5b2ad268a7c3e035edeab5f4
MD5 b959dc67d8b66c1532ec4a7f91d16858
BLAKE2b-256 fa204a5a71898e55983b9a887c42d08db65412e07a82e1339dd510ca9fb86026

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0d662eddac1cb08d73487cfe7a2115550caa938943fd379d86d8b2840c926a5
MD5 181035e86e3d9d662103bc9c3edfa48a
BLAKE2b-256 05c7e114fc26f2a7b6e4654781564b62505a5b52ef012a60ed93cc4fed946d9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 773.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.10.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 92794a445f27739ef241c192538ed21fba5cd9ed989a7f8ff35b94991e22f76f
MD5 5f44d59f9718ec663cad0fb0a00c9651
BLAKE2b-256 6e041d69fe71b53a7ca2df405336d83456f9f1e805c8a1e59e058f68d434ed11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4815ca9dddb98367c7b4bbe94a48faadfc683118dcd01d72195a66b18461f890
MD5 a33ec041724047b3f03da6da9af28586
BLAKE2b-256 a3c6501e17c9ea787ecff3df29eb87daf891865e34ca4b27d3b65f376ea9cee9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f73d49358f6ac9d60e7514289fb51388c3624ba148744bc5162da90d344c768
MD5 684784dae7a63735e20bdb379f2b930e
BLAKE2b-256 0fdfe33cbf6fcd80461b90e7f9548702653b8210483ec4cff23d63e2883312fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 766.4 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.10.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 33580cec5fc3b9338a7f92e20d084bb86603621f14c3d42752a1a5c8e7ae9df5
MD5 28942308b6f1f83f162844d60909a69c
BLAKE2b-256 cab59f32e180eebef7eb398edb3fd0d0671ef9f4593c09c4fadd1fbde87a2b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46b844140e7d763b687dd9615da2c8e6926ced5cc6da7073f3af5266009b79e7
MD5 5cbe4f9185bc438dcd454037e96fa4a0
BLAKE2b-256 4f630388aeec2666122b6c1e6eaccf7e1d02f88c46ddb8758bd0f93ec1c66ac5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bcaf5c73689ee6d2446e35ca4ba467be5695e22ad68605309677ff92ac7d877f
MD5 8326b542d84c4340e20d65c7aa6e0cb7
BLAKE2b-256 9c52e2c41c9de8032833e1ef52df1719fba861836ac5a4ae7c8a21bf988d556b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 766.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.10.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cc2bac3b3f7b5e156225e9ebbfd76212621d140903fbecd6b5938089a6ee392f
MD5 0e700786ebb73cc39c25a6a21f9c6209
BLAKE2b-256 5d843c71ea9552e07b4c92c90f3cd996f54c1e01de74e3f36568441ddd7feb4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ecd9cd46c922a28cc288347b11d750268526df860310ff5c4b78eb80010cb37
MD5 deb4f8800610405057cebc634b582ec6
BLAKE2b-256 02c5ddbed1e2b89eb6de6b9b70ca8e1507ddd5422dcb2efada645d49d5b65135

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