Who says if is check or checkmate: GUI or engine?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Who says if is check or checkmate: GUI or engine?

Post by Luis Babboni »

That´s:
Who says if any move results in check or checkmate: GUI or engine?
I guess GUI, I´m right?
The engine could "know" it for itself, but who must say if it is or not must be the GUI, I´m right?
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Who says if is check or checkmate: GUI or engine?

Post by Luis Babboni »

For example for promotions it must be the engine who needs to communicate to GUI:

"bestmove b7b8Q"

But what about if b7b8Q is check?
The engine must says:
"bestmove b7b8Q+"
or just:
"bestmove b7b8Q"
and the GUI see its check and adds the "+" for moves display?
op12no2
Posts: 566
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Who says if is check or checkmate: GUI or engine?

Post by op12no2 »

Hi Luis,

For UCI you just send the move back, no +.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Who says if is check or checkmate: GUI or engine?

Post by Luis Babboni »

LOL... just now thinking in it I understood why mate is "#" and not "++"...
it is needed one byte less (or at least the same cantity, 1, than for just check) , I´m right? :D
Last edited by Luis Babboni on Tue Mar 17, 2015 1:38 pm, edited 1 time in total.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Who says if is check or checkmate: GUI or engine?

Post by Luis Babboni »

op12no2 wrote:Hi Luis,

For UCI you just send the move back, no +.
Thanks! :)
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Who says if is check or checkmate: GUI or engine?

Post by lucasart »

Luis Babboni wrote:For example for promotions it must be the engine who needs to communicate to GUI:

"bestmove b7b8Q"

But what about if b7b8Q is check?
The engine must says:
"bestmove b7b8Q+"
or just:
"bestmove b7b8Q"
and the GUI see its check and adds the "+" for moves display?
did you read the UCI spec ? or shall I google it for you ?
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Who says if is check or checkmate: GUI or engine?

Post by Evert »

Luis Babboni wrote:For example for promotions it must be the engine who needs to communicate to GUI:

"bestmove b7b8Q"
Well, clearly, the engine needs to tell the GUI what it wants to promote to.
You need to send the piece letter in lower case though.
But what about if b7b8Q is check?
What about it?
The engine must says:
"bestmove b7b8Q+"
or just:
"bestmove b7b8Q"
and the GUI see its check and adds the "+" for moves display?
In UCI protocol, it is assumed that the GUI understands the rules of the game and handles cosmetic fluff like adding "+" for checking moves.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Who says if is check or checkmate: GUI or engine?

Post by Evert »

Luis Babboni wrote:LOL... just now thinking in it I understood why mate is "#" and not "++"...
it is needed one byte less (or at least the same cantity, 1, than for just check) , I´m right? :D
No.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Who says if is check or checkmate: GUI or engine?

Post by Luis Babboni »

Sorry :oops:
User avatar
hgm
Posts: 28515
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Who says if is check or checkmate: GUI or engine?

Post by hgm »

Luis Babboni wrote:For example for promotions it must be the engine who needs to communicate to GUI:

"bestmove b7b8Q"

But what about if b7b8Q is check?
The engine must says:
"bestmove b7b8Q+"
or just:
"bestmove b7b8Q"
and the GUI see its check and adds the "+" for moves display?
Note that the UCI move format is specified in lower case, (so b7b8q), also for the promotion piece, and I have never seen an engine do that differently. UCI only specifies that option names are case insensitive, it doesn't say this for moves.

The UCI specs do not guarantee the engine will never be presented with a position where it is checkmated. So it can depend on the GUI or the GUI settings whether it detects the mate, or possible other game-end conditions. (Like surviving on the central squares in King of the Hill.) The obvious solution when presented with a position where you have no legal moves would be to print "bestmove 0000", and indicate with the score whether this is because you won, lost or because it is a draw.