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.21.tar.gz (345.6 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.21-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (900.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rshogi_py-0.7.21-cp314-cp314-win_amd64.whl (765.6 kB view details)

Uploaded CPython 3.14Windows x86-64

rshogi_py-0.7.21-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (928.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.21-cp314-cp314-macosx_11_0_arm64.whl (850.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rshogi_py-0.7.21-cp313-cp313-win_amd64.whl (747.2 kB view details)

Uploaded CPython 3.13Windows x86-64

rshogi_py-0.7.21-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.21-cp313-cp313-macosx_11_0_arm64.whl (834.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rshogi_py-0.7.21-cp312-cp312-win_amd64.whl (746.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rshogi_py-0.7.21-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.21-cp312-cp312-macosx_11_0_arm64.whl (833.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rshogi_py-0.7.21-cp311-cp311-win_amd64.whl (739.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rshogi_py-0.7.21-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (903.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rshogi_py-0.7.21-cp311-cp311-macosx_11_0_arm64.whl (838.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rshogi_py-0.7.21-cp310-cp310-win_amd64.whl (739.1 kB view details)

Uploaded CPython 3.10Windows x86-64

rshogi_py-0.7.21-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (903.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21.tar.gz
  • Upload date:
  • Size: 345.6 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.21.tar.gz
Algorithm Hash digest
SHA256 042b5aaa3e6c64b2d2050238c9990048be48d5994560528a6df964135e0034b4
MD5 e1e35bcfaa31fa4706b4270aab19bbce
BLAKE2b-256 988077b490589f5bc271f96718b6318401d2e0a58c7a094114f3405d2546aec0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 75a0c5518923334ddded9a70134c00b696ca26958bee954db90fbef3892b828e
MD5 0a8d40003f63a524341ef90ca9e8f330
BLAKE2b-256 5180a5d3f093dd1ad1e340cc8155bf9009a7bbbef19cc17d19b8136078d1fc2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 765.6 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.21-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 db6363bcbc5dddc074468b4fa2384f77e708a8768398a38c08fdf114ec5227c2
MD5 c8b96b8321dd02057dd5b834b91ba529
BLAKE2b-256 33acff73ee0a59c53e9eaf1a6a6f47ee379e74398c130522fc4767ad610c5575

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bcb55e8e85984bd126827ec39939c2f43ba7e840e718939cc4bd2f2a78435731
MD5 6e7c92699e68d9aaab0d2425688e1e69
BLAKE2b-256 a5b716d0184251353b4d5b78a61aa1724c4cf40da8088a5a5e457dedf1055138

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81e5fda215bd783252add8b2c372e1e15f48b273a644d84895ed92c3e467d831
MD5 b97952857c4079305340daffea8631cb
BLAKE2b-256 c4176e050b5ef5fa55db6f6a2d6f105a85eac2b1532c4901ca917afbf7867107

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 747.2 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.21-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 881d5c560b2e098cce2c25cc335403894163ef2835446aebddf9b16f31462c82
MD5 b0c6f9a16b29fd3c44accc40a7c8f01a
BLAKE2b-256 d45b5ea066b37f82f4c18df45b37cc1016b97bac8c9d3766e24fa30f188bc981

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1192ea0714b5f9e3c29cfc41a2d59d2b50ae285d1194459dd5b209e718e03042
MD5 5289004ea87411103d64a47fcd0d93c9
BLAKE2b-256 64b8574896425a8b89f421feb691c9f7175d488f64981a299d3f38d1606f3120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3b4d2c51559b0ff0e9806aaf538a64bdee6cdb44222ff0b1c07d3267410befa
MD5 d4e1fea4832e52ad2d4d93c92cc105f4
BLAKE2b-256 1bc603541eb351ce56ed4208ce9434c4b2e83c192dd987378aaf9d8f6a7405bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 746.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.7.21-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 45e50a2029cfbb01c1925edf77165b64292b204796995fb86feccbd0ec99595a
MD5 54bd7272e056cd9f3435338c74e770c2
BLAKE2b-256 1d5420da85cf9a2b0727bccd58e5a633b94108ae1f1f42f5155b715427db1987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d50a012f95318196eee514badcaac3b1d549ab3c6d0896eae8fa9b2c2aff0f2c
MD5 58ad4c915411f7e96c17da84c0baf7ed
BLAKE2b-256 7232bee794d14fc9fbb42feedac21d4e20b1a65fed0f7dd614aaa5d2bc391b9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 373ec4bb0ff5a1f99acbe705bff063ff506445d0c09b26f7a9c643bb53cfe768
MD5 d29b39da90b8cc28ff3ea90164d6a4c9
BLAKE2b-256 9ac4a7721accfc3c079f7fcc69e4bf6c98c603da16538bda8432492e1606c3a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 739.2 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.21-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 55f0f40048a15e483faeb1af3d5ff73c02bcdd1455a86c7a9dd331612c79000a
MD5 c275e1e7a3f3736437ecf19b0de46917
BLAKE2b-256 1d6b0db3c044dd9467683ddaa8209c57157d6ae3acd2672c30f9ff7d62a74e2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51d2780ce64ae5ff58bb40657230b8828e66b981bd08fd4552d156382f1772b9
MD5 578d7cd659e1dedb1d56656d98f7f31b
BLAKE2b-256 d24c95d6f52439e6a94c9b76dcf549096f96e40e4910c0fd532e80cf561dc9f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5c50519ea8d76b04da864c7b1f46349195c51cabd0cb3ffc751d7aede252a31
MD5 acef96aff57f15f402d6e22b2e9c4bea
BLAKE2b-256 31f7bd901800ae9a2b426267ae24afaf0c72d376eb97e148698deda7307b43b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshogi_py-0.7.21-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.1 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.21-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d2ca959582fc807449cfbcb6f9ce451a932a676ee4d1c5962d32650cefdf5007
MD5 087ff0f470d587dda2d7f5fdae88631d
BLAKE2b-256 abb44ee755c9f1131b302efc32d07df29fd1f5c660ee0363e9ec72bbc6fca3f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rshogi_py-0.7.21-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 472f5c325c73553d48587a472f0abd10f335a7a6e80f5e319537c9c7f81dbcd1
MD5 13cb6920cda0d2aa34c0ee071c06ec6e
BLAKE2b-256 e00db2c77c5ae1f143f1d97bee466080cf88af49977328e85bc95c74f0313d05

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