linux - 使用通用国际象棋界面

标签 linux interface chess uci

我正计划制作一个与 UCI 国际象棋引擎接口(interface)的程序。我一直在对此进行一些研究,但我想在更深入地了解它之前获得更多信息。我想知道你们中是否有人可以提供一些 UCI 引擎和前端程序之间的“交换”示例。我不太关心实际的接口(interface)代码(比如发送/接收命令),那应该足够简单了。我只是想获得一些小游戏的好例子和一些选择。我目前正在使用 stockfish 引擎,但我希望能够使用多个引擎。

所以无论如何,我正在寻找一些关于如何在 UCI 上玩游戏的例子。

最佳答案

让我们假设 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 specification 中找到这些命令(another source)。您还可以查看现有 GUI 的工作原理。例如,如果您使用 Arena ,您可以按 F4 查看命令交互的日志,

关于linux - 使用通用国际象棋界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17003561/

相关文章:

java - WSDL 与 Java 接口(interface)类似吗?

JavaScript FileSystem API 作为 Chess Alpha Beta 数据存储

c# - 锐化器 4.5 : How can I discard an interface and change all references to the only implementation?

c# - 如何创建一个java接口(interface)来编译c#代码,然后生成dll的?

c - 如何在不引入锁定的情况下编写并发读取和修改定义明确的数组的代码?

java - 为什么这个棋盘运动不能正常运行?

linux - 如何将两个文件中不匹配的行存储到新文件

php - linux 上的 Memcached 未显示在 phpinfo 中

Linux - 解决 "too many open files"错误

c++ - 我在 unix 中编译代码时遇到编译器错误