Project Plateau
Project Plateau: four glass plates, one living valley, and the road back to camp.
翻訳待ち
USIプロトコル対応の最小構成将棋エンジン
Loading the full README.
Read the full README ↗Hayanagi は、C++17 で実装した USI プロトコル対応の最小構成将棋エンジンです。
通常対局用の探索に加えて、詰将棋用の詰み探索(TsumeSearch)を備え、
将棋 GUI ShogiBoardQ に静的ライブラリとして組み込まれています。
id name は Hayanagi 1.5.1。./build/hayanagi --version でも表示できますhayanagi、組み込み用の静的ライブラリは hayanagi_tsumebench / perft をひととおり実装docs/index.html)Hayanagi で学ぶ将棋エンジンの仕組み は、ソースコードを題材にした全15章のHTML教材です。 C++の基本文法と将棋のルールを知っている方に向けて、データ表現、ビットボード、局面管理、合法手生成、 終局判定、探索と評価、並列化、定跡、USIプロトコルを図とコード例で解説しています。
教材と紹介ページは GitHub Pages で公開しています。
手元で読む場合は、リポジトリを取得して docs/textbook.html(紹介ページは docs/index.html)をブラウザーで開いてください。
HTML・CSS・図版を同梱しているため、ビルドやWebサーバーの起動は不要です。
教材内のコード例や行数には執筆時点の構成が含まれます。最新の実装は src/ を参照してください。
現在の静的評価処理は src/evaluation.cpp にあり、探索処理から分離しています。
__builtin_ctzll などの組み込み関数を使います)cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
生成物は次のとおりです。
| 生成物 | 内容 |
|---|---|
build/hayanagi | USI エンジン実行ファイル |
build/libhayanagi_tsume.a | Position と TsumeSearch の静的ライブラリ(GUI 組み込み用) |
build/libhayanagi_search.a | 通常探索と静的評価の静的ライブラリ(本体・単体テストで共有) |
build/hayanagi_tests | C++ 単体テスト(Hayanagi を最上位でビルドしたときだけ生成) |
build/hayanagi_book_positions | 定跡生成用の棋譜検査・SFEN変換(HAYANAGI_BUILD_BOOK_TOOLS で制御) |
build/hayanagi_match_referee | 定跡比較対局用の合法手・終局判定(同オプションで制御) |
コンパイル警告は -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wno-sign-conversion を有効にしており、GCC と Clang のどちらでも警告なしでビルドできます(Clang の -Wconversion は -Wsign-conversion を含むため、GCC と同じ意味になるよう明示的に無効にしています)。
./build/hayanagi --version # Hayanagi 1.5.1
./build/hayanagi # USI エンジンとして起動
usi
isready
usinewgame
position startpos
perft depth 2 divide
bench nodes 10000
go nodes 5000
quit
usi に対しては次のように応答します(Hayanagi 1.5.1 の出力)。
id name Hayanagi 1.5.1
id author hnakada123
option name USI_Ponder type check default false
option name MultiPV type spin default 1 min 1 max 32
option name USI_ShowCurrLine type check default false
option name USI_ShowRefutations type check default false
option name USI_LimitStrength type check default false
option name USI_Strength type spin default 1 min -15 max 6
option name USI_AnalyseMode type check default false
option name Threads type spin default 1 min 1 max 128
option name Hash type spin default 16 min 1 max 65536
option name USI_Hash type spin default 16 min 1 max 65536
option name MinimumThinkingTime type spin default 0 min 0 max 600000
option name NetworkDelay type spin default 0 min 0 max 600000
option name NetworkDelay2 type spin default 0 min 0 max 600000
option name SlowMover type spin default 100 min 1 max 1000
option name ResignValue type spin default 99999 min 0 max 99999
option name MaxMovesToDraw type spin default 500 min 0 max 600000
option name EnteringKingRule type combo default CSARule24 var NoEnteringKing var CSARule24 var CSARule24H var CSARule27 var CSARule27H var TryRule
option name GenerateAllLegalMoves type check default true
option name USI_OwnBook type check default true
option name BookDir type string default book
option name BookFile type combo default hayanagi_book.db var no_book var hayanagi_book.db
option name TsumeMode type check default false
usiok
copyprotection checking
copyprotection ok
generate_checking_moves)MaxMovesToDraw)EnteringKingRule)This is the beginning of the README. Read the rest at the original. Read the full README ↗