Change Fen String from "r moves" to "w - - 0 1 moves"

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Change Fen String from "r moves" to "w - - 0 1 moves"

Postby tvt2020 » 14 Apr 2020, 20:12

Hi Everyone,
I'm trying to setup a free xiangqi chess engine to run on Winboard but ran into problem with illegal move when engine returns first move. I think the engine only recognizes "w moves" instead of "r moves". Is it possible to tell Winboard to output "w - - 0 1 moves"?


I can make the engine run with inbetween fen string substitution below.
[Client2Server]
; Set the translation of client command to server here.
;r moves := w - - 0 1 moves
;fen := position fen

fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR r moves b2e2

[Client2Server]
; Set the translation of client command to server here.
;r moves := w - - 0 1 moves
;fen := position fen


recognized 'xiangqi' (-1) as variant xiangqi
recognized 'xiangqi' (-1) as variant xiangqi
shuffleOpenings = 0
Version: WinBoard 4.8.0b + IBSachess
Reset(1, 0) from gameMode 0
recognized 'xiangqi' (-1) as variant xiangqi
GameEnds(0, (null), 2)
shuffleOpenings = 0
StartChildProcess (dir=".") UCI2WB "IBSachess.exe" "C:\WinBoard-4.8.0\SaChessUCI"
nice engine proc to 10
749 >first : xboard
protover 2
765 <first : feature variants="normal,xiangqi" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 pause=1 done=0
766 >first : accepted variants
766 >first : accepted setboard
766 >first : accepted usermove
767 >first : accepted debug
767 >first : accepted ping
767 >first : accepted reuse
767 >first : accepted exclude
767 >first : accepted pause
768 >first : accepted done
768 <first : feature option="UCI2WB debug output -check 0"
768 >first : accepted option
768 <first : feature myname="SA Chess 1.6 beta Dual Cores Edition Build date:230117 64 bit SSE4.2 and POPCNT(SSE4a for AMD) (UCI2WB)"
769 >first : accepted myname
770 <first : feature option="Debug Log File -string "
770 >first : accepted option
770 <first : feature option="Clear Hash -button"
771 >first : accepted option
771 <first : feature option="Move Overhead -spin 500 0 5000"
772 >first : accepted option
772 <first : feature option="Minimum Thinking Time -spin 300 0 5000"
773 >first : accepted option
773 <first : feature option="Slow Mover -spin 89 10 1000"
773 >first : accepted option
774 <first : feature option="nodestime -spin 0 0 10000"
774 >first : accepted option
774 <first : feature option="No Capture Rule -spin 120 40 200"
775 >first : accepted option
775 <first : feature smp=1 memory=1 done=1
775 >first : accepted smp
775 >first : accepted memory
775 >first : accepted done
790 >first : memory 2048
791 >first : cores 8
791 >first : new
random
791 >first : variant xiangqi
791 >first : level 50 5 0
791 >first : post
792 >first : hard
792 >first : easy
792 >first : ping 1
Impossible move , type = 0
798 <first : # setoption name Threads value 8
1681 <first : pong 1
nps: w=-1, b=-1
nps: w=-1, b=-1
2115 >first : time 30000
2115 >first : otim 30000
book hit = (NULL)
2115 >first : usermove 2116 >first : b2e2
2189 <first : 11 261 0 0 e2e6 e9e8 a0a1 e8f8 h2e2 b7e7 h0g2 b9c7 a1f1 h7f7 i0h0 e7e8
2285 <first : 12 275 0 0 e2e6 b9c7 e6e4 e9e8 a0a1 b7b5 a1f1 e8d8 f1f9 b5i5 h0i2 h7e7 f9g9 e7e3 g9g6
2861 <first : 13 315 0 0 e2e6 e9e8 a0a1 h9g7 e6e4 h7i7 a1d1 i9h9 h2e2 e8f8 d1d9 h9h1 d9c9 h1b1 i0i2
3290 <first : 14 307 0 0 e2e6 e9e8 a0a1 h7h5 h2e2 h5c5 c0a2 h9g7 e6e4 e8d8 a1d1 b7d7 d1d6 c5i5 h0i2 i5i2 i0i2 b9a7 d6g6
3957 <first : 15 322 0 0 e2e6 e9e8 a0a1 a9a7 h2e2 b7d7 h0g2 a7b7 a1d1 h9g7 e6e4 h7i7 b0c2 i9h9 d1d6 e8d8 d6g6
5248 <first : 16 314 0 0 e2e6 e9e8
5292 <first : 16 337 0 0 e2e6
5888 <first : 16 347 0 0 e2e6 e9e8 a0a1 h9g7 e6e4 b9a7 a1d1 h7i7 h2e2 i9h9 h0g2 b7b2 b0c2 b2e2 g0e2 a9b9 c3c4
6016 <first : 17 351 0 0 e2e6
6084 <first : 17 355 0 0 e2e6
6565 <first : 17 362 0 0 e2e6
6683 <first : 17 356 0 0 e2e6 e9e8
7214 <first : 17 363 0 0 e2e6
8179 <first : 17 354 0 0 e2e6 e9e8
8219 <first : 17 367 0 0 e2e6
9737 <first : 17 349 0 0 e2e6 e9e8
9752 <first : 17 329 0 0 e2e6 e9e8 a0a1 b7b3 b0c2 h7h3 c3c4 h9g7 e6e4 b3c3 c0e2 a9a8 a1f1 a8d8 f1f6 d8d7 f6g6
9754 <first : 18 341 0 0 e2e6 e9e8 a0a1 h7h5 h2e2 h5c5 c0a2 c5b5 b0c2 h9g7 e6e4 e8d8 a1d1 b7d7 d1d5 b5c5 e4d4 c5c2 d4d7
9756 <first : move e2e6
9758 <first :
GameEnds(29, xboard exit, 2)
Interrupting first
12176 >first : result * {xboard exit}
12176 >first : quit
tvt2020
 
Posts: 48
Joined: 22 Jul 2010, 17:52

Re: Change Fen String from "r moves" to "w - - 0 1 moves"

Postby H.G.Muller » 15 Apr 2020, 09:43

You are running a UCI Xiangqi engine here, which means WinBoard does not run it directly, but through the UCI2WB adapter. In native WB protocol FENs always use w/b as color indicators. But UCI2WB translates that to the FEN format required for the target protocol (UCI/UCCI/USI).

Indeed, in the case of UCI:Xiangqi, it always uses r/b. The only UCI Xiangqi engine I was aware of is Cyclone. This uses r/b, which is a deviation from the UCI standard for Chess. The protocol that Cyclone used to communicate with its GUI also differed in some other respects from standard UCI as well, most notably by omitting the keyword 'position' in front of 'fen'. I call this the 'Cyclone dialect' of UCI. Because the Cyclone engine and its GUI used to be quite popular in China, most other Xiangqi engines were created to be compatible with the Cyclone GUI, and used that dialect. To be able to run those engines, UCI2WB also uses the Cyclone dialect whenever it has to play Xiangqi in UCI mode. Hence the 'r' and the omission of 'position'.

But it appears that we are now dealing with a UCI Xiangqi engine that demands normal UCI, rather than the Cyclone dialect. First time I see that. It would be easy enough to alter UCI2WB so that it doesn't use Cyclone dialect even in Xiangqi. But then it could not run Cyclone and Cyclone-compatible UCI engines anymore. TIn the code processing the 'variant' command the line

Code: Select all
if(!strcmp(line+8, "xiangqi\n")) strcpy(iniPos, "fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR r");


is responsible for this. Prefixing the string with 'position ' and changing r -> w would make UCI2WB do what you want. But it would break its ability to run UCI Cyclone. (For UCCI engines it would not matter, as these do not load moves starting at the start position, but from the last irreversible move, for which it builds the command + FEN elsewhere, even if it happens to be the start position.)

The problem is that there is no way for UCI2WB to see whether the UCI engine it is dealing with will speak Cyclone dialect or regular UCI (or UCCI, for that matter). WinBoard solves the UCI-vs-UCCI problem by passing the user-supplied information (in the Load Engine dialog check boxes) whether the engine is UCI or UCCI as a flag argument -c or -x to UCI2WB, but there is currently no way to select anything different from UCI, UCCI or native WB protocol. Even if we would modify UCI2WB to recognize a new flag argument (or, since -c is default, distinguish the cases where there is an explicit -c or no protocol indicator at all, and only use Cyclone dialect when there was an explicit -c), it would still require modifications in WinBoard and its user interface to let WinBoard invoke UCI2WB automatically with the proper flag argument. But of course it would always be possible to invoke UCI2WB in the exceptional case 'by hand', i.e. specify UCI2WB.exe as the engine executable, and "-c ENGINE_FILE ENGINE_DIR" as command-line arguments. You would then only have to do that for engines that speak the Cyclone dialect.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Change Fen String from "r moves" to "w - - 0 1 moves"

Postby tvt2020 » 16 Apr 2020, 01:26

Hi H.G.,
I'm curious to know which compiler you used for compiling your source codes? I download UCI2WB version 4.0 from your repository, compiled with gcc cygwin64 but the program will not run. Message I got is "UCI2B: sachess.exe died on me". I didn't modify the codes just compiled as is.
tvt2020
 
Posts: 48
Joined: 22 Jul 2010, 17:52

Re: Change Fen String from "r moves" to "w - - 0 1 moves"

Postby H.G.Muller » 16 Apr 2020, 12:57

For Windows I use a very old gcc 3.4.4 under Cygwin (with -mno-cygwin option). I will try to have a look at this too, later today.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Change Fen String from "r moves" to "w - - 0 1 moves"

Postby H.G.Muller » 16 Apr 2020, 19:39

I now uploaded a version of UCI2WB.exe (4.1c) which only uses Cyclone dialect in UCI when an explicit -c protocol-specifier was given. Without (or with an unknown) flag it also defaults to UCI, but then it uses standard UCI even in Xiangqi (except that it never uses 'startpos', but the FEN of the Xiangqi start position instead, but with 'w' as stm indicator rather than 'r'). It can be downloaded at

http://hgm.nubati.net/UCI2WB.exe

You should install SaChess with UCI2WB as (native WB) engine, with as command-line parameters

debug "IBSachess.exe" "C:\WinBoard-4.8.0\SaChessUCI"

(And possibly as extra Winboard option

/variant=xiangqi

) Let me know if it doesn't work! I had no way to test it myself.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Change Fen String from "r moves" to "w - - 0 1 moves"

Postby tvt2020 » 16 Apr 2020, 20:17

Hi,
It works like a charm. Thank you!
tvt2020
 
Posts: 48
Joined: 22 Jul 2010, 17:52


Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 15 guests