2013-06-08 2 views
15

私は、UCIチェスエンジンとインターフェイスするプログラムを作るつもりです。私はそれについていくつかの研究をしてきましたが、もっと深く知る前にもう少し詳しく知りたいと思います。あなたの誰かがUCIエンジンとフロントエンドプログラムの間にいくつかの例の "交換"を提供できるかどうか疑問に思っていました。私は実用的なインターフェイスコード(送信/受信コマンドなど)にはまったく関わっていません。私はちょうど小さなゲームといくつかのオプションの良い例を取得しようとしています。現在、ストップフィッシュエンジンを使用していますが、複数のエンジンを使用できるようにしたいと考えています。Universal Chess Interfaceを使用する

それでは、私はUCIでゲームをする方法のいくつかの例を探しています。

+0

[仕様](http://www.shredderchess.com/chess-info/features/uci- universal-chess-interface.html)? 'すべての通信はテキストコマンドで標準入力と出力を介して行われます。 – raina77ow

+0

私は基本的なゲームをするためのテキストの例を探しています。 – Nathan

答えて

17

GUIが人間のユーザとエンジンの間のマッチングを容易にしているとします。ユーザーがe2e4で始まるとします。コマンドは次のようになります。

// GUI: tell the engine to use the UCI protocol 
uci 

// ENGINE: identify 
id name Chess Engine 
id author John Smith 

// ENGINE: send the options that can be changed 
//   in this case the hash size can have a value from 1 to 128 MB 
option name Hash type spin default 1 min 1 max 128 

// ENGINE: sent all parameters and is ready 
uciok 

// GUI: set hash to 32 MB 
setoption name Hash value 32 

// GUI: waiting for the engine to finish initializing 
isready 

// ENGINE: finished setting up the internal values and is ready to start 
readyok 

// GUI: let the engine know if starting a new game 
ucinewgame 

// GUI: tell the engine the position to search 
position startpos moves e2e4 

// GUI: tell the engine to start searching 
//  in this case give it the timing information in milliseconds 
go wtime 122000 btime 120000 winc 2000 binc 2000 

// ENGINE: send search information continuously during search 
//   this includes depth, search value, time, nodes, speed, and pv line 
info depth 1 score cp -1 time 10 nodes 26 nps 633 pv e7e6 
info depth 2 score cp -38 time 22 nodes 132 nps 2659 pv e7e6 e2e4 
info depth 3 score cp -6 time 31 nodes 533 nps 10690 pv d7d5 e2e3 e7e6 
info depth 4 score cp -30 time 55 nodes 1292 nps 25606 pv d7d5 e2e3 e7e6 g1f3 

// ENGINE: return the best move found 
bestmove d7d5 

私は相互作用の多くの側面を単純化しました。完全機能を備えたGUIは、UCI specificationanother source)にある他の多くのコマンドをサポートする必要があります。既存のGUIの仕組みを見ることもできます。たとえば、Arenaを使用している場合は、F4キーを押してコマンドの対話のログを見ることができます。

+2

ありがとう!私の主な質問は、次に何ですか?チェスエンジンはボードの内部状態を維持していますか、または私のプログラムはFENポジションを維持し、単に私の動き(e2e4)とエンジンが提案した最良の動きに基づいて更新しますか?内部状態がない場合、私は手動でFENボードの位置を処理し、次に "position CURRENT_POSITION d2d4"を呼び出し、最良の動きを待つでしょうか?または、私が更新できる内部ボードの状態がいくつかありますか?もしそうなら、どのように? あなたの助けに感謝、Zong Zheng Li! – Nathan

+0

@ Nathanすべてのエンジンは内部ボードを維持する必要がありますが、GUIは検索するたびに位置情報を送信する必要があります。これを 'position [FEN]'または 'position startpos [move sequence]'で行うことができますが、後者が一般的に好まれるようです。 – Zong

+0

最初から完全な移動シーケンスですか? – Nathan

関連する問題