ShogiArena
ShogiArenaは、USI対応の将棋エンジンを自動で対局させ、結果を比較するPython製のツールです。 エンジンの強さの検定、パラメータの調整、自己対局による学習用棋譜の生成にも使えます。
ドキュメント | クイックスタート | PyPI | 変更履歴
できること
| やりたいこと | ShogiArenaの機能 |
|---|---|
| エンジン同士を対局させる | 総当たり、基準エンジンとの対局(gauntlet)、並列実行 |
| 変更前後の強さを比べる | 対局結果から統計的に検定するSPRT(GSPRT) |
| パラメータを調整する | 対局結果を使ってUSIオプションを調整するSPSA |
| 学習用の棋譜を作る | 自己対局、SFEN/KIF/CSA/バイナリ形式での出力 |
| 複数のマシンで対局を回す | SSH接続によるリモート実行 |
設定、棋譜、対局結果は実行ごとに保存されます。 途中で止めたトーナメントの再開や、保存した結果の集計もできます。
ダッシュボード
https://github.com/user-attachments/assets/1cdebe23-b1a9-4d8e-91c0-f56ca970b569
ブラウザで進行中の対局や順位表を確認し、棋譜を再生できます。 SPRTの判定やSPSAの更新状況も表示でき、終了後に保存した結果を開き直すこともできます。
インストール
Python 3.11以上が必要です。 Windows x86_64、Linux x86_64/arm64、macOS Intel/Apple Siliconで動作します。
pip install shogiarena
shogiarena --version
対局に使うUSIエンジンの実行ファイルと、そのエンジンに必要な評価関数は別途用意してください。 エンジンの入手から試したい場合は、クイックスタートにYaneuraOuと水匠5を取得する手順があります。
インストールの詳細はインストールガイドを参照してください。 SSHでのリモート実行先はLinux x86_64のみ対応しています。
最初のトーナメント
手元のUSIエンジンを二つ登録して、動作確認用に10局対局させます。 同じエンジンの設定違いを比較することもできます。
まず、次の三つのファイルを同じディレクトリに作ります。
engine_pathは実行ファイルのパスに置き換えてください。
working_directoryには、エンジンの作業ディレクトリ(通常は実行ファイルのあるディレクトリ)を指定します。
WindowsではC:/engines/engine_a.exeのように、/で区切る書き方も使えます。
engine_a.yaml:
name: "Engine A"
engine_path: "/path/to/engine_a"
working_directory: "/path/to"
options:
Threads: 2
USI_Hash: 256
engine_b.yaml:
name: "Engine B"
engine_path: "/path/to/engine_b"
working_directory: "/path/to"
options:
Threads: 2
USI_Hash: 256
ThreadsとUSI_Hashは、それぞれスレッド数とハッシュメモリ量(MB)の指定例です。
使えるオプションはエンジンによって異なるので、必要な評価関数のパスなども含めて、エンジン設定を参考に調整してください。
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
この設定では2局を並列に進めます。 各エンジンの持ち時間は10秒で、1手ごとに0.1秒加算します。
ファイルを作ったディレクトリで、設定を確認してから実行します。
--dry-runでは設定と対局予定を確認できますが、エンジンは起動しません。
shogiarena run tournament tournament.yaml --dry-run --run-dir runs/first_tournament
shogiarena run tournament tournament.yaml --run-dir runs/first_tournament
実行中はhttp://localhost:8080でダッシュボードを開けます。
棋譜や対局結果はruns/first_tournamentに保存されます。
結果を見る
終了後も、保存先を指定すればダッシュボードで結果や棋譜を確認できます。
shogiarena dashboard serve --run-dir runs/first_tournament
端末で勝敗を集計したり、JSONやCSVで出力したりすることもできます。
shogiarena results summary runs/first_tournament
shogiarena results summary runs/first_tournament --format json
shogiarena results summary runs/first_tournament --format csv
対局結果を強さの比較に使うときは、completion_status.jsonで終了状態も確認してください。
正常完了と途中停止の違いや、集計から除外される対局の扱いは、トーナメントガイドで説明しています。
Pythonから使う
同じ設定ファイルを使って、Pythonスクリプトからトーナメントを実行できます。
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())
USIエンジンを直接操作して局面を解析するAPIもあります。 使い方はPythonライブラリガイド、関数や型の一覧はAPIリファレンスを参照してください。
詳しく使う
用途別の設定テンプレートはexamples/configsにあります。
pip installでインストールした環境では、GitHubから取得してください。
開発環境の準備や変更の検証方法は、コントリビュートガイドにまとめています。
ライセンス
ShogiArenaはMIT Licenseで公開しています。
Metadata
Release files for shogiarena 1.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shogiarena-1.3.5.tar.gz | 2.2 MB | With provenance | Details for shogiarena-1.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shogiarena-1.3.5-py3-none-any.whl | Python 3 | none | any | Details for shogiarena-1.3.5-py3-none-any.whl |
Total release size: 4.0 MB
Release files / shogiarena-1.3.5.tar.gz
| Download URL | shogiarena-1.3.5.tar.gz |
|---|---|
| Size | 2.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdf0c853c78a44e2d525215d4f888827830ddb381d431f0822b4e365f3462865
|
|
BLAKE2b-256 checksum How to use checksums |
830cb998293ef28f398be76add201fa586ac83c41509e5f49884f055a13cc1a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / shogiarena-1.3.5-py3-none-any.whl
| Download URL | shogiarena-1.3.5-py3-none-any.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
166f539391ba89af0404b06a7f98d72f8fa6de780838cd012b63cbb3993065d3
|
|
BLAKE2b-256 checksum How to use checksums |
840ad44d675a67dfb08b09312d3cf61faa4c804f58312387f216c580f2cc47ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for shogiarena 1.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for shogiarena-1.3.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.