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.8.0.tar.gz (349.9 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.8.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.8.0-cp314-cp314-win_amd64.whl (773.8 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.8.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (934.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.8.0-cp314-cp314-macosx_11_0_arm64.whl (856.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.8.0-cp313-cp313-win_amd64.whl (756.3 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.8.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.8.0-cp313-cp313-macosx_11_0_arm64.whl (837.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.8.0-cp312-cp312-win_amd64.whl (755.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.8.0-cp312-cp312-macosx_11_0_arm64.whl (837.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.8.0-cp311-cp311-win_amd64.whl (747.7 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.8.0-cp311-cp311-macosx_11_0_arm64.whl (843.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.8.0-cp310-cp310-win_amd64.whl (747.7 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0.tar.gz
  • Upload date:
  • Size: 349.9 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.8.0.tar.gz
Algorithm Hash digest
SHA256 243793befb1ff88aaf635f526c464d2a1135e12b032ba3c47cd481eacf0c5584
MD5 70d365d8f8eb202b5f0f808f88a10ebe
BLAKE2b-256 8d65adff8aa2d98f9dd01e1bb636ab9a76f417a3d953c53e143dd05eade0697b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48550f80bb2ea9400f99e75f8f6ad50b04f738865700060d59aa60ece6d0a387
MD5 99ebd13b8074335d9f67896863f33064
BLAKE2b-256 c939c4c13d66f5eb6d5fc332b952393ef4435cfde315bacf5378654c41b34ae0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 773.8 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.8.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 052a56c8a1a69045b25757390b364c8c3f049182436e0161980db20f3af2472d
MD5 c17c956ff8e77e5cc89b53bd7f2de81a
BLAKE2b-256 83e9a0b0164fe9d152641b27d3e9a89cca7f120495ac3d67ef0e7e934c6eaec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f919e9a678729b8fad4dd8e943ba3afd15b3a7c208832167d80c1b7a0abf49e6
MD5 9ad0f94bcc8dea64fba169a9d5b35f73
BLAKE2b-256 8ea21f909ff9697c393f6eb985c709b1b2aae43301b436a8f7650c86cc6a2b69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b7dc8bca131a69af7f653cb100cf1793556dfa342de7629c4c83dd49d5d453c
MD5 48ed4d0b258d43946160cd367f8d80f9
BLAKE2b-256 e13f37ec0303ccbd68d20fee97e85295dbc5f15105834b38b148d454122d3706

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 756.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.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5b9cc31dc6ffc43316c4681f03e83ed3f117e7c5984bc5d096cc0af8354880f1
MD5 82cfcaff520a658df8cba40f9b8e2ae9
BLAKE2b-256 c42efab1d31a7eb5038cd2211a16d8d17d54403c7a190f13c3b66c76cb1d3600

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e39b0e188ee7a07b5bb7b9f177c94ce07c8734a3f65fd780bdc8aeda65233e44
MD5 3f7623a6682d921925771b62ab770b33
BLAKE2b-256 33a85c4c2416381ea0cda3aa4ac600f9b28dd83088dca0cfa87b7bd160812857

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cd57d705cd20a9f0a55b1fdcff81412df619c34e0616290e563a6177bcf7599
MD5 d6fdf76404ce6e2b61518797cc20a8ea
BLAKE2b-256 efc9b44d5c58643b64a5f51f65d2dd71ee6b9162111552f98a310513e6494ef1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 755.5 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.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3f68de736b8ed29ac5a981dccce4719ceca65ee531206ca41f5e89246d113f81
MD5 3216c954cc9e7b3291846c34bac771c5
BLAKE2b-256 b0c5e48c644abd48950575106ae9e9f896ad30e8ae9ba9542aaa6eee45297595

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 efcff71edc65232bb4f6882f94501b4a3cd6c4aff84b7083a0b350ae8b7b81ce
MD5 2740448b8cf789a976d5924bdc9fc994
BLAKE2b-256 421928a125635df489ca813293216dc1162e51e19d914e05e8165148a3d37bfa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ba8410b81f26a4ec2a33586e4fd761f8985558439471464ec58fd415be8c9c13
MD5 0eede9b523b955cb14d6c5c3af0abf75
BLAKE2b-256 8825b138cee1046b39a7d8c592714651242a255de83b6fd1282d09f64713235d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 747.7 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.8.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e31250e53cbc5c245364cd9627dca794af38c6254c3cf9646bf4b934afcaf801
MD5 b518d49a34bd47b351328ac1b09869f5
BLAKE2b-256 7f449679558d89b797d477d8a6a1624ee580a216765fcbe0a5752d5fcfdec1fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7d9cd964d031f5e34f58b5457b606cb2fb1e3415c2d40062fc98bf0e8cce3ca
MD5 182cc4710ff2db18bb787244aa1abcdf
BLAKE2b-256 560cea4628c3edb611ad4d81f6557a52cbc2a79db5dbf403250314bb54bb89f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c687ab887868804883350f075c1212d5b19102ff0d210c5bbe15286ec974cd2
MD5 c6faa67c288b06ab1ae74aa944955d86
BLAKE2b-256 84bf8a9e158ea702e3d8a76a978a8b817808c09c70ded9705fc8b87185a290c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 747.7 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.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 14dc372c4262ec619d771b354008e4b90938e0b58c7664e1353190e0733178bb
MD5 c80e636999d6313e642ed3f3afeb5800
BLAKE2b-256 ad71b04ffbd9f96dbec01dd0329127e6bbad987945ea8e75d26747695af62acb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 260ee254e7348206d29e3a5fe0cb57d2ee19a763ccfa31c3daf33e37e3e49d92
MD5 a3bdb80b1f6e363bd9157a3aefcb76fe
BLAKE2b-256 67b361580fe554355f88ca18b4ad0681c22d0ca3f2b34c607ece9db0f55366c4

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