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.10.3.tar.gz (381.4 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.10.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (969.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.10.3-cp314-cp314-win_amd64.whl (892.7 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.10.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (995.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.3-cp314-cp314-macosx_11_0_arm64.whl (899.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.10.3-cp313-cp313-win_amd64.whl (873.3 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.10.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (979.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.3-cp313-cp313-macosx_11_0_arm64.whl (881.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.10.3-cp312-cp312-win_amd64.whl (871.9 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (978.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.3-cp312-cp312-macosx_11_0_arm64.whl (880.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.10.3-cp311-cp311-win_amd64.whl (865.6 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (970.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.10.3-cp311-cp311-macosx_11_0_arm64.whl (886.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.10.3-cp310-cp310-win_amd64.whl (865.4 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (970.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3.tar.gz
  • Upload date:
  • Size: 381.4 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.10.3.tar.gz
Algorithm Hash digest
SHA256 dda3f76cb7d40b2b97a6b170731f54935a845d2edafe4844ee6d1a5f8e6063f2
MD5 b77e76a1985ba76576d3d9d9e716bd7a
BLAKE2b-256 ed8c0712e3bf10776546b83b02fd906e51468e72d0ca0d0f51ca64fe89bc661f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b222e271b417966a8d63cc2faf3c11d7c9d68d72df0cda3a345b84de1fd69f69
MD5 9568c005996da92a370c62e49aa3c233
BLAKE2b-256 5da8cc27572a540e38ba3936a335242307d0853b40ae5a796ccc66a4fc4b45e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 892.7 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.10.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 af5207a95fe85ef4c73da339db82dce05bca5a209ee5184bcb4fac2a606a846f
MD5 9587f62efbf6cdc9378e444f2d7b3594
BLAKE2b-256 dc60cca1e9895709929fa3d0c72baab62893e7b6c695ae8653f640073cda8211

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab9ba05127806b6fc401f8dcccfa2a4bed3b6a125f9c3e8336b9630a09802da2
MD5 7de256e84f3aaec5e7711337fb47c828
BLAKE2b-256 a879215431e5d8560294e33d4c859a84b30904456e2f70f7f64911fd4b60ae2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60c1ebf92e408d3a3d0b1b6e3c8b2d16fb1358e0bcb0695ea364fef18391995a
MD5 c617778521cd7d57006509e2b3eb7b47
BLAKE2b-256 8d19b1e5634a3b499c2b2e65e50dfccee75d8667951d5de7a24e5669114c55de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 873.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.10.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 98dec53835a8daf9257ff4c8bc396fe8e8bf2b11a9ffae3e1927f0461e4e8c3d
MD5 6208fa5151d35420323191f936b2e0f7
BLAKE2b-256 3dec5ee88ab9b86ce1d1cb15936b376a3f9bbbe6e1f11eb46b93e3cd5517f4dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba1b1eb51be895aaa8820cad3bbae202ac572836032e6f72059c80b5e7213dec
MD5 140154eeeb0e763d55dd1adf899d0a9a
BLAKE2b-256 df802625d992671e4433d9db726b73e79735b5ba64876af73b78116aa9daa5d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2683b2e5e94e89f60a77955c07657b0d66cab779b45e5d02b671af324371d438
MD5 e0319cea4ac2512231384b6d7ee3a580
BLAKE2b-256 35cc0afbd3c40699e93047e6c631c266b3e911f42faf7453dc5cf04ee891df83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 871.9 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.10.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bf855b2160f483304bd9f75fc296aa7c2ba3eb594eefe3f9b66a3e81cc0531f5
MD5 232c13a63d69ebb97b82b2cbd59029ad
BLAKE2b-256 dc48b04b2aafae230436e035b2745202697da19f41c7e22705fc0aa069e1e08a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9fb51d1c32659c255db137c5246602a345e13a0d4aa796ef58144dccdf9702e0
MD5 a54e195fe7d809f7c99699923b1a3154
BLAKE2b-256 b6911f03bcd93ea6223863ca7c29c27d37a9aae5f50ad602701a702263406585

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb1431dff294329d1d02578e17ee7dfa3b057280194bce2509e24aea8a5489e4
MD5 5daae79390be963f6b4d7229ad3e2b15
BLAKE2b-256 73438b0cefe4b3460b63e70bbfddc5ddb66c245dc7daa68d5ff6bb0271cf9220

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 865.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.10.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f30581e377f881a508c9e189738fd2be9bfaedffec9703773494c503deb13f17
MD5 a1bd2c71dea08646107ca2f8fbd72a6d
BLAKE2b-256 b4c77ef8d95d99d5b8f082d3139b12b2f1c2e8b5deb361e24b0fc90b2601e0e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3297d6449e4c4f77b87644c74a985b8dc1bb6e800563e348d42b0e4c6ef47a92
MD5 b4a87f1d43bd2fc55aeebb068b61d81e
BLAKE2b-256 3a66ac67a4396391c34836729bbcbe29c6b7819dd6d8ba854f3ceee0a55619be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8da1358e4a0d0c9ab4b35d22c14ba141b37442ad8c5955bcbc90fe24a183ca8
MD5 d8c39989197cd7ab86b54cf165127204
BLAKE2b-256 38b7b768fdb9806847fd0a5626e5d3a03ba27c1d00a36d272de0c27dd42dd05a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.10.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 865.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.10.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f46133bd9cd5934071d3589336a6587e01b0a14784e6a69be11ea7c7bed8a65e
MD5 bb1e6725182ed4195904f0ba4b124119
BLAKE2b-256 95b89278c198c3ee178d6a7db6ee75c3cb6d00a745c56eb3f6bbd5fd8e58326e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55aee2e6568f7f086e823a9361103797f9f5ae349dbc1c0e31cb0f6a87acb8ab
MD5 16197a601d5ec9e7f7c9f8210657e56e
BLAKE2b-256 60fd9e9a59834917fb734c2ee72ff95393839b4e362229561cbe2ea985429934

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