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.11.tar.gz (328.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.11-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.11-cp314-cp314-win_amd64.whl (750.8 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.11-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (916.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.11-cp314-cp314-macosx_11_0_arm64.whl (843.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.11-cp313-cp313-win_amd64.whl (733.5 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.11-cp313-cp313-macosx_11_0_arm64.whl (824.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.11-cp312-cp312-win_amd64.whl (732.6 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.11-cp312-cp312-macosx_11_0_arm64.whl (823.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.11-cp311-cp311-win_amd64.whl (725.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.11-cp311-cp311-macosx_11_0_arm64.whl (832.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.11-cp310-cp310-win_amd64.whl (724.9 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11.tar.gz
  • Upload date:
  • Size: 328.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.11.tar.gz
Algorithm Hash digest
SHA256 af097ff51cfdb1f4f6a972c067dd9d068aaecb0ab064212a9a55b2f64584321e
MD5 df2e7676b18e37d9259c6d932f0c09da
BLAKE2b-256 b4d843f48c80516f42d4490f4a171f991bcf539b784ea2b70266283640976e76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7245e47553101cc46a1e51241249f14d0e382f3b75c435a460ea0aa6f27f291
MD5 89b348b8045f4c9be4f2fbf722694557
BLAKE2b-256 df0d8563d5c889c89221053daeac623eb0411d380273bd463196fbe97f5ce58c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 750.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.11-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b9a33f00096098cba6134d0786bfd776ed864b47f2fb54ad6d6c679eb40abe6d
MD5 fa2af6a0c7898cd7976d8fed06433031
BLAKE2b-256 44f4fd1d08e3506f88364f649654d7b109cd3561c6895d44205881ed799ab504

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd56edc8d1511170c804a07ff4f2ee035c70296f81e3815722c7dc1907e7bf65
MD5 d7a7eaed15d36b5a6d85bb92da1ba516
BLAKE2b-256 52cd05ac1265eab12f183a096d5ae12e943ab28c5bd21a17df23a17fa1e89a42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c30621bc923171cc0e2ec1cc2914f0e3f09abf67d4e2625e121559583be6b1d
MD5 c2250c4e24da9bb23bee9169abb59e14
BLAKE2b-256 5443d7710c4c296a12964c5c98762dc14ba286670241e4660bca7b9a9fd98350

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 733.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.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b822741d04e3b7a0fcbacbd6236759aa7bc89aeb4254d182981bebf2bc30cc99
MD5 db5f240197794e3736dc9546a23619f7
BLAKE2b-256 22ca081b03a491a18dcb8997b4b31883b8cbf3e2ae99006b62971954fcb54766

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6c45c8528e318b1f7b07c6ef2ee9cdf0580307af9f0d86c8191b521b1757b6b
MD5 7e73e2656a5bfe71930c79c74d0f7d11
BLAKE2b-256 91b17c7e9a3f3104fa2cef8472082c24282da49cb1be040e237bf9ccd7f02f13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2d4be8c8d0d2da2cd6357cc1448a0cfcb75025d55cb255ae72c665df7e62d1c
MD5 19ba6130ff9cb5af0189fab6618f685b
BLAKE2b-256 ae70dd214dfdd0aac9775ca0b8abd84ed6eb602f62075d298d52895810298b9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 732.6 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.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cb397fd87ce68f8749943487c0f9d90a6ef833c6df05a1f7b5880e58e93b5669
MD5 05d8189f0c72255963b0e10c15d94797
BLAKE2b-256 b144d1e5b2d54ba917a9e13d4976c08129fbcd5928122580524890b6677d0952

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d321fc630e3b6d744b55a9124db36f0b2d7aed2e19e3594f28521cd460967e68
MD5 15e7934b29f6361cca33eadc03bb6510
BLAKE2b-256 1a1cff6d8aa83a647d6aad93569919c70a3b081480c690a3a84f40c7d9f3d2a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38a579a28038c1a9c9c059c3935216a32645f849907e6a5d299262bf3c998f9c
MD5 9a3e3796512488216525b2c5998293ee
BLAKE2b-256 d5a68449cf4855393ac9b4ec3181cc9834895c45f1427e7442b395429770988d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 725.1 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.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e0d0a7ae397b0c9ef3a3f4c21757aeac0caae641a19384a279dfe47c82e50b2e
MD5 a1e1b893e65c9b7d049d8ea9292622e1
BLAKE2b-256 934625ac0e1ce3b9470defa7b437095d2dc039e5db22a248b9b3da18e01d6396

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ca6327fe4a76d9b4ccca7693ea04c0ca58d83906ba167025719a47af0d2de73
MD5 7778208024d33fccdb8c5ca3d0af9de4
BLAKE2b-256 016f420a2f04697952ee35a523fe21ceecbf5cb5df78911d83c960b6a77bf6b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b81fdef3705513d24b4030ee4f0e3950276b7b26877efdc824ac9cb31177200
MD5 12c9eb5255ad21b53289472797f02a6a
BLAKE2b-256 1ff6ffae48342d96f373dc83173dd9cd7ebd7a8bf5baddbd42e5ffa2e188bb32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.11-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 724.9 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.11-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 874075b3bf8cca26ae98890b8e4108e2ce8c8d5b9bc7b1b9af546e97cf61a96e
MD5 5fb7f5e7356e099021548d7d96658d4f
BLAKE2b-256 38178aa255884920e98d60276bd1fd5938dd2cf0d19db907244740ddd8cfad6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b60425e733170938bd1e3aeec11295fdef4b4ce0a1ff83e3616e5fbb15f46e09
MD5 7ccb58f8f8134242e58d01b69422b02d
BLAKE2b-256 e0d497d0094ade324af88cfb59214e2c81e8c5eccb5241895c43c734f3d31f93

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