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.9.0.tar.gz (341.3 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.9.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (848.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.9.0-cp314-cp314-win_amd64.whl (774.3 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (874.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.9.0-cp314-cp314-macosx_11_0_arm64.whl (795.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.9.0-cp313-cp313-win_amd64.whl (756.9 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (856.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.9.0-cp313-cp313-macosx_11_0_arm64.whl (777.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.9.0-cp312-cp312-win_amd64.whl (756.1 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (856.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.9.0-cp312-cp312-macosx_11_0_arm64.whl (776.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.9.0-cp311-cp311-win_amd64.whl (747.6 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (849.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.9.0-cp311-cp311-macosx_11_0_arm64.whl (783.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.9.0-cp310-cp310-win_amd64.whl (747.6 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (849.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0.tar.gz
  • Upload date:
  • Size: 341.3 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.9.0.tar.gz
Algorithm Hash digest
SHA256 69f7b5165e15b03eae5d580ac3bfc5abc396442c271feb1d17e091e7beea268a
MD5 84110963ce484dddbc13a6e19d359c2a
BLAKE2b-256 538a976e2812b44956f7e3fc8344766b581e29ea947006a7787d9725a5600c91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5a8f275d3880e1d509bc2dd4d98aced50dd70189b9b969afaeb77ee574807da8
MD5 e154b63c417c5e1b7a30bbf8773a23e4
BLAKE2b-256 5afd7583a7359a1db20181f3d04b609865341596ca96f6bf2ab31444e7983e4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 774.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.9.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b093345ec2e09cb20f094f59c302f842b1dce14d8534e027d3c1fe89b821d9dd
MD5 32a0730d058fe648bb639f391254cb72
BLAKE2b-256 bb2fe8507eaaccf3984f16267a207c5ae6ce2cb4d165fd4a4883de2ea726a97a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eaabfabcf49834568a47a1299734cd36320f41d0f12e1dc1275ce45e5a58d78a
MD5 fa13780f07ae27c80478425c72357e5a
BLAKE2b-256 eb6a3c7cd0423acbed92ef6004ec70aee862ace631434a82215811b15f1de160

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b7e4e3e566f5ed2ae7061d63361da288963bd4f29d38f7853538cac76e32855
MD5 9f05fb0b1b02b2ab2c99543e71851e6e
BLAKE2b-256 5f0493bb19f04d017536e54f71cc52a0d130b13dcd782c1a49eb40a97850dc64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 756.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.9.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 13baacaf2b1d3abc7cd72a62eb2569f18fd0be17f8c6e4a1c4154908b3cacac3
MD5 69aecb68b6bb4b8b6cd439c0b8aee340
BLAKE2b-256 d142324873b158419a956954bb0da64a1d6a46aa1312e2b7c72fdae289085d0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79cf1231258827610c0ec8c548e47bb1574bbc0b2b03bb51b0910d6fb2bb55a6
MD5 873094af748cbc71f8f9aef0c1cfd02f
BLAKE2b-256 5c379190b83b79be1f2765b4e22df8705b44d10858be8d7affe14e216d2ba3dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88c1e5d2d8d86b82fb0ae27704cd70f67a822787943682d923e8fc32bb4e18fa
MD5 b609d58c010660646c17d6b36a746396
BLAKE2b-256 5c6c2240132b662c13e407421e720b989c4cda0a097a45c3a019cf2bef195134

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 756.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.9.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6962c20814a21e611128f95eccba9ea4512849a1c1d82670dcc8aac8d8761f63
MD5 f598a7948dcdbd425c8a08760890eccd
BLAKE2b-256 3e0ab55f5eb9e3563d605653a8898f6921b1fff1d817ca1803896f2ea2d40a0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa26cd57b5e8456cfd8f8fb08a7e15470eb15e5d4bebba215ab1b09e56f930b3
MD5 2e312b56feb65cccfbdb3be16b3539d4
BLAKE2b-256 50017effd37c5a3d6ebfb0254205bccc2acb02069a3c9495fa7e164abd8f54e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad30626f3be438cebb09b6e2d5be60cd97f16428cbb7410cf21b3e7ee4eebf81
MD5 2a63cfee170d534d5c1e1c38064bb635
BLAKE2b-256 345d163455565bd0f732f90cced62ee6461d8ff06641b516311bc612d75400b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 747.6 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.9.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e8ba3e79f8b11ce105a4f74cc3c5023fe386788d222485e2186513bcbfb708f
MD5 374360bf1b9750c36379a314fde3d0d1
BLAKE2b-256 8bb0a97354a550c8eec1e76c33cb5d90ddaae9a9962387f432a4aaa1fbf85782

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c99fb9e056b4c931cec8ba6d57d94be82197f151b0047e4ffae57e100493411
MD5 4534708069f5d181c793fbf5fddd0df4
BLAKE2b-256 a40dcba8d9466e6edeb739d8a379bd6d875a96c1d1ab9311e1e6e16821306f80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ea644af65818eeb36358357f4599d9d0e456921da8bac3a03cb21cb8e9d6f77
MD5 13b77c4106102dc95d11daf9208d616f
BLAKE2b-256 17324c6fe07b03cc255e32e1b2e2cf0ff3ae3aec5258169d4f9397f322bc53a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.9.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 747.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.9.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f0ce4b5f860c6f5f5e25fa44135c86b5e7b5ac2dd2285e6a1d7c1c505dc75b5e
MD5 974e28d40b0c7fa796218ca922a5b279
BLAKE2b-256 ee555a35b55bf6e1c8b9003febeedfd27632a516c8ca014a993ba54fea8533f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7aea7bdb23392fdd46d2a9c1d89dcf3ebbc39751b3cb30532471f52be6d6d5a2
MD5 b94b7f8ff584915da640cdb1a5f6a09f
BLAKE2b-256 004ddd528974349e44bcbd5db8eb50b103db83cdc6ea285a6546684016a6e744

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