fairy-stockfish / Fairy-Stockfish

chess variant engine supporting Xiangqi, Shogi, Janggi, Makruk, S-Chess, Crazyhouse, Bughouse, and many more
https://fairy-stockfish.github.io/
GNU General Public License v3.0
615 stars 192 forks source link

Support Xiangqi via UCI #530

Closed nguyenpham closed 2 years ago

nguyenpham commented 2 years ago

I have known the engine supporting Xiangqi via UCCI. However, UCI is still more than enough for Xiangqi (as well as other variants). Using UCI makes the engine easier to be supported by chess GUI and more consistent.

ianfab commented 2 years ago

Fairy-Stockfish does support the UCI(-cyclone) protocol as well. If there are issues with its implementation, let me know.

nguyenpham commented 2 years ago

I can't turn its board into Xiangqi with standard UCI (not UCCI / UCI-Cyclone) commands. The command to set up Xiangqi is setoption name UCI_Variant value xiangqi. Below is the screen content. Clear the engine displays the board and gives the best move wrongly (not Xiangqi).

nguyenpham@Trevors-MacBook-Pro src % ./stockfish
Fairy-Stockfish 101022 LB by Fabian Fichter
uci
id name Fairy-Stockfish 101022 LB
id author Fabian Fichter

option name Debug Log File type string default 
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 33554432
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min -20 max 20
option name Move Overhead type spin default 10 min 0 max 5000
option name Slow Mover type spin default 100 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name UCI_Variant type combo default chess var 3check var 5check var ai-wok var almost var amazon var antichess var armageddon var asean var ataxx var atomic var breakthrough var bughouse var cambodian var capablanca var capahouse var caparandom var centaur var chancellor var chaturanga var chess var chessgi var chigorin var clobber var clobber10 var codrus var coregal var courier var crazyhouse var dobutsu var dragon var embassy var euroshogi var extinction var fairy var fischerandom var flipello var flipello10 var flipersi var gardner var giveaway var gorogoro var gothic var grand var grasshopper var hoppelpoppel var horde var janggi var janggicasual var janggimodern var janggitraditional var janus var jesonmor var judkins var karouk var kinglet var kingofthehill var knightmate var koedem var kyotoshogi var loop var losalamos var losers var makpong var makruk var manchu var micro var mini var minishogi var minixiangqi var modern var newzealand var nightrider var nocastle var nocheckatomic var normal var okisakishogi var opulent var placement var pocketknight var raazuvaa var racingkings var seirawan var shako var shatar var shatranj var shogi var shoshogi var shouse var sittuyin var suicide var supply var tencubed var threekings var torishogi var xiangqi var yarishogi
option name UCI_AnalyseMode type check default false
option name UCI_LimitStrength type check default false
option name UCI_Elo type spin default 1350 min 500 max 2850
option name UCI_ShowWDL type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 7 min 0 max 7
option name Use NNUE type check default true
option name EvalFile type string default <empty>
option name TsumeMode type check default false
option name VariantPath type string default <empty>
option name usemillisec type check default true
uciok
setoption name UCI_Variant value xiangqi
d

 +---+---+---+---+---+---+---+---+
 | r | n | b | q | k | b | n | r |8  
 +---+---+---+---+---+---+---+---+
 | p | p | p | p | p | p | p | p |7
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |6
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |5
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |4
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |3
 +---+---+---+---+---+---+---+---+
 | P | P | P | P | P | P | P | P |2
 +---+---+---+---+---+---+---+---+
 | R | N | B | Q | K | B | N | R |1 *
 +---+---+---+---+---+---+---+---+
   a   b   c   d   e   f   g   h

Fen: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Sfen: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b - 1
Key: 097ED51E44E52F54
Checkers: 
Chased: 
go depth 10
info string classical evaluation enabled
info depth 1 seldepth 1 multipv 1 score cp 53 nodes 20 nps 6666 tbhits 0 time 3 pv e2e3
info depth 2 seldepth 2 multipv 1 score cp 23 nodes 47 nps 15666 tbhits 0 time 3 pv e2e3 b7b6
info depth 3 seldepth 3 multipv 1 score cp 91 nodes 85 nps 28333 tbhits 0 time 3 pv e2e3 b7b6 b1c3
info depth 4 seldepth 4 multipv 1 score cp 61 nodes 294 nps 58800 tbhits 0 time 5 pv b1c3 b8c6 e2e4 b7b6
info depth 5 seldepth 5 multipv 1 score cp 100 nodes 380 nps 63333 tbhits 0 time 6 pv b1c3 b8c6 e2e4
info depth 6 seldepth 6 multipv 1 score cp 37 nodes 1921 nps 120062 tbhits 0 time 16 pv d2d4 d7d5 c2c3 b8c6 e2e3 e7e6 g1f3
info depth 7 seldepth 7 multipv 1 score cp 46 nodes 2871 nps 151105 tbhits 0 time 19 pv e2e4 e7e6 b1c3 b8c6 d2d4 d7d5
info depth 8 seldepth 10 multipv 1 score cp 38 nodes 6221 nps 200677 tbhits 0 time 31 pv e2e4 d7d5 e4d5 d8d5 d1e2 d5f5 g1f3 b8c6 d2d4
info depth 9 seldepth 13 multipv 1 score cp 53 nodes 14879 nps 286134 tbhits 0 time 52 pv e2e4 d7d5 e4d5 d8d5 d1e2 d5f5 g1f3 a7a6
info depth 10 seldepth 11 multipv 1 score cp 68 nodes 20380 nps 328709 tbhits 0 time 62 pv e2e4 e7e6 d2d4 c7c6 b1c3 d7d5 e4e5 f8e7
bestmove e2e4 ponder e7e6
ianfab commented 2 years ago

The UCI protocol requires a position command before running go.

nguyenpham commented 2 years ago

OK, I got it now.

However, the problem is that you have been using a strange coordination system when rows are counted from 1 to 10. I think we typically count them from 0 to 9.

nguyenpham commented 2 years ago

We also use E for Elephant, not B; H for Horse, not N.

ianfab commented 2 years ago

The xiangqi community uses UCI-cyclone and UCCI which use the 0-9 coordinates as is common in xiangqi. The chess variant community mainly uses the generalized UCI protocol which as a natural generalization of the 1 based chess rank numbering uses 1-10. I follow both conventions as appropriate for the respective protocol.

nguyenpham commented 2 years ago

That means you have just created and followed your own new standard for Xiangqi. I knew programmers have full rights to do what they want. However, it is much better if you follow some standards or de-factor standards since it is easier for other chess GUIs/tools to support and reduce the chaotic situation in the Xiangqi standard.

The standard of PGN for Xiangqi is from the below link. It is similar to XBoard/WinBoard:

https://www.chessprogramming.org/Chinese_Chess

gbtami commented 2 years ago

You complained Fairy doesn't support UCI. Now you know it supports it. Then you complain Fairy doesn't support Xiangqi standards. It follows both UCI-Cyclone both UCCI. Don't start this meaningless debate again, please. All the possible argument was repeated in https://github.com/ianfab/Fairy-Stockfish/issues/194 countless times. Just read that :)

ianfab commented 2 years ago

All xiangqi software I could find that supported the (non-cyclone) UCI protocol were using the 1-10 numbering, so I was in fact just following existing standards. As gbtami mentioned this was discussed to death before. Please at least read existing documentation or discussions before claiming you know better. There is nothing wrong with asking or constructively criticizing, but discussing in such an assertive way especially when being new to a project does not come across very nicely.

If you want to contribute to reducing confusion about chess variant standards anyone is welcome to join my effort to document existing de facto standards at https://fairy-stockfish.github.io/chess-variant-standards/.