ShogiArena
USI将棋エンジンの対局、比較、チューニングを、一つの実行環境で管理します。
ShogiArenaは、トーナメント、GSPRT、SPSA、自己対局による棋譜生成に対応しています。 対局の実行だけでなく、設定の検証、棋譜と統計の保存、異常の診断、Webダッシュボードでの監視までを同じrunとして記録します。
ドキュメント | クイックスタート | PyPI | 変更履歴
ダッシュボード
https://github.com/user-attachments/assets/1cdebe23-b1a9-4d8e-91c0-f56ca970b569
進行中の対局、順位表、棋譜、エンジン設定、SPRT、SPSAの更新状況をリアルタイムに確認できます。 完了したrunも同じ画面で開き直せます。
用途
| やりたいこと | ShogiArenaの機能 |
|---|---|
| 複数エンジンを比較する | round-robin、gauntlet、並列対局 |
| 変更の強さを検定する | trinomial/pentanomial GSPRT、早期停止 |
| USIオプションを調整する | SPSA、共有乱数、LTC回帰テスト |
| 学習用の棋譜を作る | 自己対局、SFEN/KIF/CSA/binary records |
| 対局を監視して調べる | Webダッシュボード、USI transcript、結果集計 |
| 複数ホストで実行する | ローカルinstance、SSH instance pool |
各runには設定、エンジン情報、棋譜、SQLite DB、再開状態が保存されます。
v1.1.0以降はcompletion_status.jsonも保存されるため、正常完了、SPRTの早期決着、利用者による停止、安全装置による停止を区別できます。
インストール
Python 3.11以上と、実行するUSI将棋エンジンが必要です。
pip install shogiarena
shogiarena --version
Windows x86_64、Linux x86_64/arm64、macOS Intel/Apple Silicon向けのwheelを提供しています。
AVX2版のrsshogiへ差し替える場合は、インストールガイドを参照してください。
実行platformの対応範囲は次のとおりです。
| 用途 | 対応platform |
|---|---|
| Coordinator/ローカル対局 | Windows x86_64、Linux x86_64/arm64、macOS Intel/Apple Silicon |
| SSH Remote worker | Linux x86_64 |
Remote workerはworker-bundleでwheel、lock、manifestからimmutable bundleを生成します。
別のuv projectの仮想環境へインストールした場合も、bundle sourceにはinstalled ShogiArena distributionを使います。
既配置engineや評価ファイルを使う場合は、preplaced-mapで実行時と同じlogical IDとSHA-256 mappingを生成できます。
shogiarena worker-bundle build --output worker-bundle.zip
shogiarena worker-bundle preplaced-map \
--engine engine-a /local/engine-a /opt/engines/engine-a \
--resource engine-a /local/eval /opt/eval/engine-a
Remote設定とcas/preplaced運用はリモート実行ガイドを参照してください。
出力先とエンジン配置先を初期化する場合は、次のコマンドを実行します。
shogiarena config init
shogiarena config show
config initは必須ではありません。
{output_dir}と{engine_dir}のプレースホルダー、artifact repository、共有キャッシュを使う場合に設定してください。
最初のトーナメント
ローカルのUSIエンジンを二つ登録し、10局のround-robinを実行します。
まず、エンジンごとに設定ファイルを作ります。
engine_a.yaml:
name: "Engine A"
engine_path: "/path/to/engine_a"
options:
Threads: 2
USI_Hash: 256
engine_b.yaml:
name: "Engine B"
engine_path: "/path/to/engine_b"
options:
Threads: 2
USI_Hash: 256
次に、二つのエンジンを参照するtournament.yamlを作ります。
experiment_name: "first_tournament"
engines:
- engine_path: "engine_a.yaml"
- engine_path: "engine_b.yaml"
tournament:
scheduler: "round_robin"
games_per_pair: 10
num_parallel: 2
rules:
time_control:
time_ms: 10000
increment_ms: 100
dashboard:
enabled: true
api_port: 8080
実行前に--dry-runで設定を検証します。
shogiarena run tournament tournament.yaml --dry-run
shogiarena run tournament tournament.yaml
実行中はhttp://localhost:8080でダッシュボードを開けます。
設定項目の意味とrunディレクトリの構成は、クイックスタートにまとめています。
実行モード
| コマンド | 用途 |
|---|---|
shogiarena run tournament CONFIG |
round-robinまたはgauntletを実行する |
shogiarena run sprt CONFIG |
二つのエンジンをGSPRTで比較する |
shogiarena run spsa CONFIG |
USIオプションや評価パラメータを調整する |
shogiarena run generate CONFIG |
自己対局で棋譜を生成する |
shogiarena run analyze |
一局面を通常探索する |
shogiarena run mate |
一局面を詰み探索する |
設定テンプレートはexamples/configsにあります。 PyPIの配布物には含まれないため、必要な場合はGitHubから取得してください。
保存したrunを調べる
ダッシュボードは実行中だけでなく、保存済みのrunにも利用できます。
shogiarena dashboard serve --run-dir /path/to/run
対局結果を端末、JSON、CSVへ集計できます。
shogiarena results summary /path/to/run
shogiarena results summary /path/to/run --format json
shogiarena results summary /path/to/run --format csv
v1.1.0以降の測定結果を採用する前に、completion_status.jsonのstatusとtermination_reasonを確認してください。
ShogiArena自身の停滞が疑われる時間切れと、原因を断定できない時間切れは無効局として記録され、EloとSPRTの標本から除外されます。
Pythonから使う
公開APIからUSIエンジンを起動し、局面を探索できます。
import asyncio
from shogiarena.engine import UsiThinkRequest, create_engine
async def main() -> None:
async with await create_engine("engine_a.yaml") as engine:
result = await engine.think(
sfen="startpos",
request=UsiThinkRequest(movetime=5_000),
)
print(result.bestmove)
asyncio.run(main())
保存先を指定してトーナメントを実行する場合は、shogiarena.tournamentを使います。
import asyncio
from shogiarena.tournament import run_tournament
async def main() -> None:
result = await run_tournament(
"tournament.yaml",
run_dir="runs/example",
)
print(result)
asyncio.run(main())
安定した公開面は、CLI、公開設定schema、shogiarena.engine、shogiarena.tournamentの通常利用向けAPIです。
shogiarena.compositionの高度なrunner/storage組み立てAPIはprovisionalであり、1.xでも変更される場合があります。
shogiarena._coreは内部実装なので直接importしないでください。
ドキュメント
開発
このリポジトリの開発環境はuvで管理します。
git clone https://github.com/nyoki-mtl/ShogiArena.git
cd ShogiArena
uv sync
make check
変更を送る前にコントリビュートガイドを確認してください。
ライセンス
ShogiArenaはMIT Licenseで公開しています。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shogiarena-1.2.0.tar.gz.
File metadata
- Download URL: shogiarena-1.2.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c90d5751ae81f744961cccb87f9d9d9eb0cb6af3b88a8f7b754cb5aef8473bd4
|
|
| MD5 |
0dbde99dc71d553d0c85233ffb207134
|
|
| BLAKE2b-256 |
0dd7b0b4b1555a305e673e13eb7cb70910f5dd6e1d49f4d6a51251675c59d5aa
|
Provenance
The following attestation bundles were made for shogiarena-1.2.0.tar.gz:
Publisher:
public-release.yml on nyoki-mtl/ShogiArena
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shogiarena-1.2.0.tar.gz -
Subject digest:
c90d5751ae81f744961cccb87f9d9d9eb0cb6af3b88a8f7b754cb5aef8473bd4 - Sigstore transparency entry: 2309408092
- Sigstore integration time:
-
Permalink:
nyoki-mtl/ShogiArena@295215662d3e9146721c548ac1843bf739fa2060 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/nyoki-mtl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
public-release.yml@295215662d3e9146721c548ac1843bf739fa2060 -
Trigger Event:
push
-
Statement type:
File details
Details for the file shogiarena-1.2.0-py3-none-any.whl.
File metadata
- Download URL: shogiarena-1.2.0-py3-none-any.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25fb892101dd4fad78fc6291e6d1f608eea96ff5bd93275e1abc879a42ae50f1
|
|
| MD5 |
e004a16a98b859f9cfcdcdb596babc0b
|
|
| BLAKE2b-256 |
0cfeda8ee1b5825bbe2091d86564f172b9c3275443f0b7e85e68b9954fa69431
|
Provenance
The following attestation bundles were made for shogiarena-1.2.0-py3-none-any.whl:
Publisher:
public-release.yml on nyoki-mtl/ShogiArena
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shogiarena-1.2.0-py3-none-any.whl -
Subject digest:
25fb892101dd4fad78fc6291e6d1f608eea96ff5bd93275e1abc879a42ae50f1 - Sigstore transparency entry: 2309408265
- Sigstore integration time:
-
Permalink:
nyoki-mtl/ShogiArena@295215662d3e9146721c548ac1843bf739fa2060 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/nyoki-mtl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
public-release.yml@295215662d3e9146721c548ac1843bf739fa2060 -
Trigger Event:
push
-
Statement type: