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.19.tar.gz (343.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.7.19-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (901.6 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.19-cp314-cp314-win_amd64.whl (765.3 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.19-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.19-cp314-cp314-macosx_11_0_arm64.whl (850.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.19-cp313-cp313-win_amd64.whl (748.1 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.19-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.19-cp313-cp313-macosx_11_0_arm64.whl (834.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.19-cp312-cp312-win_amd64.whl (747.3 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.19-cp312-cp312-macosx_11_0_arm64.whl (834.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.19-cp311-cp311-win_amd64.whl (739.3 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (901.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.19-cp311-cp311-macosx_11_0_arm64.whl (838.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.19-cp310-cp310-win_amd64.whl (739.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (902.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19.tar.gz
  • Upload date:
  • Size: 343.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.7.19.tar.gz
Algorithm Hash digest
SHA256 b99b7ba79eb196798406957a0338230063caec01e1dc63054842629bf05fd1f6
MD5 ea34872c57fbeb5f994179d935afbd84
BLAKE2b-256 5ac8cba4c7dd1a5556369b1528a1da20b527b68209fda250c6f15a0617725722

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 261afd2e926d4392d9d38d149466b23d0edc18a6092171a1c1b74071db6f34ce
MD5 71183b1be405228135fe3bd5de5b8812
BLAKE2b-256 d1626c8e28b094e8815f88ada953aff9775aafc76b827d7de1741bda49aa7237

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 765.3 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.19-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 99a93f2ac0b70386f85e664880dffe352ae75fcc44bd7886f3e1c5f2f7891d41
MD5 7b6f44d053d1740317123bec9d268ca1
BLAKE2b-256 7b52ddff8eacadf74558fdcc2ee334a6b87c17ed2331dbacabc8033ca9bd9b13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92cbe24b330d0bc8e5d6a1464bfc18ab3226acd4b2378fd119f3ffbba195fe79
MD5 32cffcc25184e66344f3735364f6ee8f
BLAKE2b-256 faa9f45ea2e6599c9c9fddbc33cf559b488f5116a720229befc9ffe8db779db2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 865c4a877a9cdd46a53a8dfa2da21acf7bdd9082504ffd41118508e9163a7b5e
MD5 1e464f186d07c97f759148dce1a5b43a
BLAKE2b-256 74db66b36c8d5aa11d561eb59677e6486acd8e1a2b634fe53eecdeaf0578be6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 748.1 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.19-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 09966c040e5f8af3eee47ec6b77591672ac547af873002c36cc7d2c279b95562
MD5 77dbd6709ce1d98983321dff9d6b4043
BLAKE2b-256 b5e825e9972b67897cdf7483f726ffbb9c86db3341ff2dc9f77a2394abaa8671

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24e7be86c178e66170088e970dd05c45ef34618028bde0798e8f10f545ca83ec
MD5 572c4ca022c86b4922f3cdf08ead4519
BLAKE2b-256 3fb0745bb9e8cc579ded044510a992e9e16ea218e547870734e29d973f6038e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 04279ed3fc811bd2d069b8db55db649e2156557a515e49ff23bc3235425dc27d
MD5 fda71298f6bf71c1834a8bb103e41540
BLAKE2b-256 779a0b968efa10609b059b0c56e8f6e95e8d2fd290b61f53b50f8026874a73ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 747.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.7.19-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1f430a289f2a012b02d8cb28dfb7addfcd02434573209773ad76fdda44f98eb0
MD5 6e2519259473ab408ae3f4ee30db388c
BLAKE2b-256 9f17a711b8f8745d2d769e31cb7ca72bdb639786626ef2704ae6ed5201433a7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8a8d9bc0ce5c7a7700d612670cd31eb27c30554ff4de8ae18f189de4a2b2e0a
MD5 6a751acd743539e304f38612d89d32d8
BLAKE2b-256 7d4ceff5e314640632e601b7ec4f805ae547cad0eca9fc8556ba252953a0fd7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c39315247a89c6243e750cde60379dc8d110761aa382d6ffa18e0926552ae0b
MD5 693d80f3f2d02216b04fda93909ab216
BLAKE2b-256 36e7897cfeef92cd468c91066e51506ed18a921e356bb17cce4ef970d13e0272

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 739.3 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.19-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ff8f5e0271a16f1c539c5cbbeb4f8c2cdb46f6d314daa7d532ed4f3509133c2f
MD5 516a76d28318a921ff91e41515402230
BLAKE2b-256 21c43009b5baf6a726c1c247527f9794e3261537e91f3ef490c8ec6987be05de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 171f327a23fcef1688bd16b1daffbf4f1ee68908faa5dbfb2487b1585d354e03
MD5 9c5732aa78aa83885567aaa072bd90e7
BLAKE2b-256 0fc2423577cd429150a1e7d6216001f650c7524167e412aa533766b839d28b8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed409077dd31acde6d8ce89533d965c75ed54e856dd07ac1ccdada34a0051364
MD5 d08436c0b41dcb70d65b4464e0e8f62a
BLAKE2b-256 0029357df2665193767fb0d14a7cb3d35678996529220e43f5c4bccbfc9ec0ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.19-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.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.7.19-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b720994f570dd74b5c1a9759f6de8f96c9c17fde58fb36c6e652ef9400727eaf
MD5 71e3fdbaac3ccf85719b8655e76f319f
BLAKE2b-256 40db663aa16c82ff3b6903e3838fb67b8f2fcc9c2ccfe40a42b28dd9f12a5014

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d692d0430f6c808c04b9e9a37e008fd993c337b4cf0d66b6b536fa258afd16c9
MD5 8d4f0135cd358defce06d84aadee266e
BLAKE2b-256 42a2129232ab0a4bbebe243b6b820039beea78e8df5b5fd6d0672cd48cb582d8

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