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.2.tar.gz (376.1 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.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (913.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.10.2-cp314-cp314-win_amd64.whl (840.9 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.10.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (940.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.2-cp314-cp314-macosx_11_0_arm64.whl (849.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.10.2-cp313-cp313-win_amd64.whl (820.3 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (922.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.2-cp313-cp313-macosx_11_0_arm64.whl (832.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.10.2-cp312-cp312-win_amd64.whl (819.3 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (921.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.2-cp312-cp312-macosx_11_0_arm64.whl (831.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.10.2-cp311-cp311-win_amd64.whl (813.9 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (914.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.2-cp311-cp311-macosx_11_0_arm64.whl (838.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.10.2-cp310-cp310-win_amd64.whl (813.6 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (914.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2.tar.gz
  • Upload date:
  • Size: 376.1 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.2.tar.gz
Algorithm Hash digest
SHA256 6cb5a098a829a9498c468e26209279eddcaabe2c5cb38005a5af481992163b30
MD5 80ae79550f5019bfb2fa97daf1cb62f4
BLAKE2b-256 c6f851bb37b5ec63d3366d4d8c702fa2ee832f3c5e016fc3a9a66dbb43487a7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 449b15fc3604d8b256e29bb33d1ca846337394746448b4d53b53b3f4af212f16
MD5 8ff73f27440b75cdb685bf203480f35b
BLAKE2b-256 2511f158f19ef425a2aff2c80a0835d8c08b02be4bf8aec398d2bb87331c8d6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 840.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.10.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c2f4a7b5e980d098ed7587b5038906a5d6bbb1c6044b1b46b649040d11b39474
MD5 e3c99905c888051c2c61915c4c929893
BLAKE2b-256 163a7f70e43747374a760f03ee3f9941fc35e7c050ce54695f76e0e6e8abe8ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b0132199147c048d4ddc63ae7bb10bbdb67e58f4f145e29446c0c09c8c52fec
MD5 250fba30095a905581d8a28aafa4d2b6
BLAKE2b-256 60f72cec3bc4f871c2dbc70af1bd8c9695767d9ac4f1da4bae41e6b7715bf4da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 680725f152f1a5388d9b5617bc0d59e49aa7de9b367f0a26df6109957e62851f
MD5 d87ca18096cf1a6ab7611d0c6b142f38
BLAKE2b-256 82ae5f018b687d49e1d942adab4627735c3aeabaf6a013b2d61305babe98d023

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 820.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.10.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4d7b6c0ca99a36c0acf1e9749d26b5a41fb24365bf68465f22169c3dd66515d6
MD5 55e9a1820c013dfbef7c7be95df2c8aa
BLAKE2b-256 a645e74eda828745655395cf45a613578a1519907a513897195daccea437d8cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 006d3965559cf0d6fa6056a48b06cdadddd92aede3759f5794f650c859e3c63a
MD5 87a8384e57b06cb0f7c5cc935409d3a7
BLAKE2b-256 85c76de2758ff0e3c35c1ee3a0f22694eb7eb2edfd4d56228c0a674a04c3f851

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78b20fd1210c6364d928268120f24131cdc99b71bd6a2c1b3d9a84f09a446fca
MD5 f981f8f7c3a1e2bf65960c5f9fa116cf
BLAKE2b-256 95f184c5040bcd84ef36c541acdfd33a74fc5e737cb686823b36c53ece32d767

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 819.3 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 160d37c37b2c82cd25656d25107e04cdaa55572f596ebd76f93d055c7eb06e64
MD5 62f69f14670f3dad8eef8f51bde44c6d
BLAKE2b-256 92d25614e66c4c6aa10e00dde455e5bd3a398b96dbcca7618af0153c8c5bb2e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 39e8b0eb6efcfe0dc25e52efabfee217555e6a0701e557b5cf7a8ee54ab88da3
MD5 7dd635014a475508e452059c79a9688d
BLAKE2b-256 51f3a1a4e1dfbe00d2bea5370f3966491f720fc01e42a2a6e1dfde74a36ac628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 528f51d068b9d6956f004b1797a95f894400bc3f0fe1d221b13b0237800c99fb
MD5 c65c11d418c53315f388247e5940d541
BLAKE2b-256 5a69d25a60ef6c30599487c62d4244ff2bfc6a38620762009621bea773c39802

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 813.9 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5e3f56c436696d297307497ce3773cb9909f1215c463bd38e23e6c5da8a6d220
MD5 46ecfd7bae234941b4e7076c502797e7
BLAKE2b-256 70724e048d50546ba4ae313cf2feb7bcf8f2bbc94b787bffe363703af0767638

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd0e978f97d467593d38c05698e8ee9784121f9d694e2363c0d9edae7365568a
MD5 e0750333959753337845f3b481df9f8e
BLAKE2b-256 d2ccb8574eaa2f1a57155500efb103ebfb41540bd4f0e0ca983c02e26cc185ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ec4d39dd256caca61990c1dc6ffa21e45b118818fa6d1835cf5e2147852311b
MD5 d438168514aa6e4deaf7ebbf1090f988
BLAKE2b-256 e6ab3c1597424465b730a7e3460f8f704daf84b6b75811cbeef491d0afbc772f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 813.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.10.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 88405b419065389da064acc9945a5ef93548638628fcf5f8ba9724b419c58b14
MD5 13b63a870fafb876a4465cd53361cb01
BLAKE2b-256 843ade06982aad2057507dfded05b15c406ec99f676795461c0d13b6b7eed58c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87227bde6ae136aa4bc10dd87a9c8dfbbbd4dfb2c6544fe5b091d5932c04f8d2
MD5 e63415c00e09dbe9587c58875b64db3f
BLAKE2b-256 23b98fad503fd9f48e36df4525f3d5caeaebe46327c9ee27c5811076e56f4509

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