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.20.tar.gz (345.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.7.20-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (900.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.20-cp314-cp314-win_amd64.whl (765.0 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.20-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.20-cp314-cp314-macosx_11_0_arm64.whl (850.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.20-cp313-cp313-win_amd64.whl (747.8 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.20-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.20-cp313-cp313-macosx_11_0_arm64.whl (833.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.20-cp312-cp312-win_amd64.whl (747.2 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.20-cp312-cp312-macosx_11_0_arm64.whl (833.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.20-cp311-cp311-win_amd64.whl (739.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (902.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.20-cp311-cp311-macosx_11_0_arm64.whl (838.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.20-cp310-cp310-win_amd64.whl (739.1 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (902.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20.tar.gz
  • Upload date:
  • Size: 345.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.7.20.tar.gz
Algorithm Hash digest
SHA256 7a17fc82e3ca838f5560dc309a3dbdad691cba33bbacafae24373fe8805be4b7
MD5 f918033df522ce3f4f63ceb507a97f91
BLAKE2b-256 d10358bac98db99388da9a9e73057e12788334e6cf4ba34dfa06acf235e79838

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 356b6a104666d6dcec5bac5793ff13b730b7502525470a6a262b5f09f9f3fd8d
MD5 c9ee1353a5a9e7ba5e5ab57b95e33b76
BLAKE2b-256 ffd8c398863119cbc788689276c2d7a3d5de0e1857e19a2daa8160890db21c4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 765.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.20-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e0cd8138ffb95d40c6ecead7c341d8c8cd62712b16bd1bea553cf28a4a995697
MD5 31ff5428536c533c7f06e0aa0a5a8b28
BLAKE2b-256 50aa963ab8c6e3ff873038aece3082ec41cd482954b1f74effad444f84a27d0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35a5530847fef0ceeb70aa69d5bf6f62063ed371cfb80981d0d5151cfbdb5ceb
MD5 6f3433fa5277b8515e42171261cd9310
BLAKE2b-256 583ee327f1d96d10d164a241db99704105def5cb85b6fa0ab956e8952d9d15e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1b555eca2b31d7f45d421bd9f39a1148211192ecd48599d56a204ca72b64857
MD5 ac5d0bf5179b7d26806c11c9fd0eae74
BLAKE2b-256 76dc6630ecdba1e9c30578c90f7fb97396e0ec6d10e49252a411118939458738

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 747.8 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.20-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fdc354b9084675db083dba23a93bddd079e4d5deb901d2b718589e77001e4722
MD5 bf4a56bb07e1ccee052fb9e6eb8dfb68
BLAKE2b-256 0c4f011ab336ad97283bf9ae565ef78b1af5cad4d1dcabb8547d907ad9957f76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b721c08a6fa9dcee0580fbe9220cfff739d7ac4c38982e05ede0670feedaf87d
MD5 592caf3439c80a54cbd0249d4d31ecc1
BLAKE2b-256 1c0d6f81ebac1f89217628655dd73c88d79e4d112cde05d2f8426cda8839506f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 432bb7fcc1f8fbf367a83c3f4ebc0efb1a93588dd16a548ac3d49fb379f918ed
MD5 789e41e3663793021c05dd10b5f6ac67
BLAKE2b-256 5ecc5e1c35cf1549b8e7cb749134372dc317138c732d480971662fb1f35a8acc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 747.2 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.20-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 63e34f3b80cb3a8fc82464ab300c61b1e6fbe52d5c39d7d83ab746dd578af865
MD5 48a47cb48acfa19ee56e69995ce6bd53
BLAKE2b-256 e6235ebff8a16cc8d6c47c40e67f47c945cb2c68f66211ac2947229d15269956

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ad95fca67ff7ce39c0776f93a5932199eea7795746515c57d30074ab2ac729b
MD5 199874b5a82303fee69b44772edfbed4
BLAKE2b-256 ff5b1ad35974e2b507be3c6a64d86e8b0fcece2c1c0dff0f803be2f7d9a5fd00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf0a8d4939353f6aaa8731f8e02e56b95ee8befd2e0b4679f9371567e7632c8c
MD5 a942a87f485f36a7d193362bba36f2d9
BLAKE2b-256 565055523e26e557bfb2c5788c2789d7acfe89b1d2f698a2b678fa07b43e36a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 739.2 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.20-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 03d00ba2f4c112f1ce69e9fbd274d9da31edb6220d16c0179d27f2e4fc52443a
MD5 47ff83772b3244b7f114e00c1f2b9004
BLAKE2b-256 0a81795c437ab4706ed7f27cbabcedc800575679d38045214d1ecce16d757595

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 adfc383d182c710e250f80e6b512d932028088f699e6c14921c95dc6ed4ab09a
MD5 3185b4ea37ca68dbf8fe39f90ede8888
BLAKE2b-256 2be0ece8ac906f5642a9266bfee6509647e4e0e3dedde32581bb29ce061b9b73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58c200f228879f32a8b7359e3fba33cee4a83c1012f52db5d6ff3f415b7c1813
MD5 b4d01b2e30838fffbfee68c79b2334e5
BLAKE2b-256 f9e3ab89e0111ad7947b7d377d76ce093d6cda976d5df57fdb6c77d655a60617

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.20-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.1 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.20-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c4f14a3fecb480cd00ef98d85dd5b7b89f9fe784fd50537c592c886aecc48b37
MD5 e153a495267b1b2fddbd7b3bfa37b0ee
BLAKE2b-256 ed4ff974f4448f750a0f0b5878531bedb1f517cd54c53b7288a83131cd3f61f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18f594b06c3e9fd77957515cf6968244969832f063870e470e74bbfe1fdd74c5
MD5 6c7500ed0057c08b53d1daf9ceb82386
BLAKE2b-256 b7f3c28b5f5af46ceaeb0a30198ee0183375a86b9e4050b82af67b808397f453

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