I'm planning on making a program that interfaces with a UCI chess engine. I've been doing some research on it, but I want to get a little more information before I get more in depth with it. I was wondering if any of you could provide a few example "exchanges" between a UCI engine and a front-end program. I'm not really concerned with the practical interface code (like sending/receiving commands), that should be simple enough. I'm just trying to get some good examples of a small game and some options. I'm using the stockfish engine currently, but I want to be able to use multiple engines.So anyhow, I'm looking for some examples of how to play a game over UCI. 解决方案 Let's assume the GUI is facilitating a match between a human user and an engine. Let's say the user starts with e2e4. Then the commands would look something like: // GUI: tell the engine to use the UCI protocoluci// ENGINE: identifyid name Chess Engineid 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 MBoption name Hash type spin default 1 min 1 max 128// ENGINE: sent all parameters and is readyuciok// GUI: set hash to 32 MBsetoption name Hash value 32// GUI: waiting for the engine to finish initializingisready// ENGINE: finished setting up the internal values and is ready to startreadyok// GUI: let the engine know if starting a new gameucinewgame// GUI: tell the engine the position to searchposition startpos moves e2e4// GUI: tell the engine to start searching// in this case give it the timing information in millisecondsgo 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 lineinfo depth 1 score cp -1 time 10 nodes 26 nps 633 pv e7e6info depth 2 score cp -38 time 22 nodes 132 nps 2659 pv e7e6 e2e4info depth 3 score cp -6 time 31 nodes 533 nps 10690 pv d7d5 e2e3 e7e6info depth 4 score cp -30 time 55 nodes 1292 nps 25606 pv d7d5 e2e3 e7e6 g1f3// ENGINE: return the best move foundbestmove d7d5I've simplified many aspects of the interaction. A fully featured GUI will have to support lots of other commands that you can find in the UCI specification (another source). You can also look at how existing GUIs work. For example, if you use Arena, you can hit F4 to see a log of the command interaction, 这篇关于使用通用国际象棋界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 22:11