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.17.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.7.17-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (900.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.17-cp314-cp314-win_amd64.whl (764.8 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.17-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (926.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.17-cp314-cp314-macosx_11_0_arm64.whl (850.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.17-cp313-cp313-win_amd64.whl (747.5 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.17-cp313-cp313-macosx_11_0_arm64.whl (834.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.17-cp312-cp312-win_amd64.whl (746.7 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (907.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.17-cp312-cp312-macosx_11_0_arm64.whl (833.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.17-cp311-cp311-win_amd64.whl (739.4 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (900.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.17-cp311-cp311-macosx_11_0_arm64.whl (839.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.17-cp310-cp310-win_amd64.whl (739.4 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (901.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17.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.7.17.tar.gz
Algorithm Hash digest
SHA256 b446f8e9a2e8c202d8c9af9f2a9f7ab1f6402b6a8a3b5f149096c00fdfb61b1b
MD5 0e6228e2c1bfaf90ad55fc5bdd33ac65
BLAKE2b-256 f006296c6af0defe2e3149ffa91a6914b7da0978d15c90565fe05f07b760610f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d31d81d465694ef2706b14e394c71987bcb850ae0fa7504a0e598873918af2b3
MD5 7c774d68b6bbf4118bc215b143d7c0e6
BLAKE2b-256 b89edab0629274c49abccf22272e113f9067a258199ab3d74e5ccb645466d2aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 764.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.7.17-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 36510d89bafef7b75c2df74d809b70b9f616a15612f09155cc185419e7f7a9d1
MD5 655c498143892d5426ddab4d24dbb499
BLAKE2b-256 bad34a47a8fef49ad4db0518a28b4aab6e14cf162f303799d8eaf7d251e7076b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca3b0a236bcb5e1099155f9bb86289fba1790dfd35a47bd1c84a9f2b2c0b4693
MD5 b9fbeb323c236dc67d2faf0616d84299
BLAKE2b-256 7dbc264d3e2650f0fb78b43c3a836cc5eb8b22db3883bbf8a3d13e1c7460d521

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 704ea1ac7bfa9797f9fd3c10979c7812c3d22e9658587627f3455aaf349dbe85
MD5 34765e7867fe89ccb901e3b1a524c46c
BLAKE2b-256 0ad2aefa80bce2151f19c02a8809e3308e2cc9f27cfdadcf10f815e1eba84213

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 747.5 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.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 180bbe19559a42a13fa9697c9e9fb3be9caa99533ace42ebf1d94cef3d35b747
MD5 5b90fcc30284957b8540353300295bb9
BLAKE2b-256 729f23fb070e42e6d3a4f2c3d792d39426dbe16ddba621b6cf9f58f4a482af63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84389be65edb363774012f1c37b65f5c9e422b5aa9b69e342d72405f2649ce96
MD5 a04bc6e148159d66208a7460cc1078e8
BLAKE2b-256 94f2030a0b5370f38cb31633168a97a3bcab5f0a7add00b559613d3022d30f3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70aac1eb01cba4163615df82e6ecce3994103072a8baf7f99e3db5a042d2eca3
MD5 fa7d23dd2559aa5e30f3b80e594449f1
BLAKE2b-256 c42b76444a17fc394f6e6d78f629ecf4c1882c1364199b55f222447ace6e72b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 746.7 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.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a305971d44fcfcc3c7405a273f6c48a2562d960bc7c54a8171666bd5db43ec13
MD5 fc4e6f692bf61e4788a59e464c24d2a2
BLAKE2b-256 1ae4fee17de20b6040f5e836df21e67be38f5f83ff50a01ca77af1a1e3ed3421

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c17e737fa0cb2642de9e038e3adc29b85c9db975a15bf7c48578b25943a5afc0
MD5 fa9fdc5c583a4af45d18f96d82c21c16
BLAKE2b-256 37cdee804aedab21009bc15d48b5f82f73ead08533a63e42fe581333dd0d4167

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40f07c54e6a857daccd3f97d14cf4cf0c858aeb2e7c7c41d7daa1209cf730165
MD5 50fac9ea9a8233dbca8b54c17d307d27
BLAKE2b-256 e29f87c6bc0efb56e898dd8fa70535191eedb7d18b19a2849f552145b7ab377c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 739.4 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.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dcd9384edcd4779034ac52e95e38308e319138d21d4f4a80f142638a45c5c18f
MD5 8e721d9a8be0b49222da380b33382722
BLAKE2b-256 97f9a50fcc0332401541a1c460842eb2f08aa9998ee698a2a1cf77ecef0c7c99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c345687317899af21472587dcfdd1ad1cea84accc8c55b4d8e95b4af2a6f866b
MD5 b66d4ca32242048fda13f03797e5cf09
BLAKE2b-256 2b0df6d811ae43ead86a7e47427c7606ed2476af4fc89ee305be6ef8c2ec05ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32cb25b327aa7b836c665b56c091b841894209cd65697c55f8e3950f20fc5fd6
MD5 0db89ad931d85f3b69f1d37785bb7071
BLAKE2b-256 64d8cd2344710348cb397b580c5dd4ae73d18d46134acb69ff1cd3889d49e4bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.17-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.4 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.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8fe6a6a301b40a6278147148542beb3049fd7685459d1d9345e2f5b89bab8587
MD5 9b146c617a8c8e73ea64839ee9bcc242
BLAKE2b-256 27fe9e51dca1130ff54948dc869641b970f7d54cbaf364291eea6c86f159e7b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e798473ccf0593c556f3f2d7c851e0b53c8020907f93c3af33c5ae9cb2edea52
MD5 803a23d7f6808abfd4b1937a05206b4d
BLAKE2b-256 eea29f0e1758a501b24885850606d0e3d4443322e5d105bd70fc6933948bda2e

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