Question about Sjaak

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Question about Sjaak

Post by Michel »

While testing icsdrone with Sjaak it appears that Sjaak rejects O-O as castling notation during fisherandom. I think this is incorrect according to

https://www.gnu.org/software/xboard/engine-intf.html#8 (section "MOVE").
Fri Apr 1 12:46:02 2016:DEBUG:ics->icsdrone: <12> bnrb-rkq pppppppp ----n--- -------- -------- -P--P--- P-PP-PPP BNRBKNRQ W -1 0 0 0 0 0 1061 GnuCheese dado53 1 2 12 39 39 138 143 3 o-o (0:01) O-O 0\015\012
Fri Apr 1 12:46:02 2016:DEBUG:icsdrone->engine: time 13800\012otim 14300\012
Fri Apr 1 12:46:02 2016:INFO:Move from ICS: O-O O-O
Fri Apr 1 12:46:02 2016:DEBUG:icsdrone->engine: O-O\012
Fri Apr 1 12:46:02 2016:DEBUG:engine->icsdrone: Error (Illegal move or unknown command): O-O\012
Note that the ICS board gives the situation _after_ the castling move.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

I'll look into it. It should always recognise O-O unless that option is deliberately disabled (which gives a warning that this will break shuffle variants), so this seems odd. What version is it?
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Sjaak II version 1.3.0 (x86_64)

BTW Sjaak prints so much info during start up that it exposed a buffer overflow in icsdrone :-)

EDIT: It is not so much the amount of info that triggered the bug, but rather the fact that sjaak prints very long lines.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Michel wrote:Sjaak II version 1.3.0 (x86_64)
Hmm... seems to work for me:

Code: Select all

./sjaakii-1.3.0 
Sjaak II version 1.3.0 &#40;x86_64&#41;
Type 'help' for a list of commands and help topics
 8r n b q k b n r 
 7p p p p p p p p 
 6                
 5                
 4                
 3                
 2P P P P P P P P 
 1R N B Q K B N R *
  a b c d e f g h 
#&#91;Chess&#93; 0w>setboard bnrbk1rq/pppppppp/4n3/8/8/1P2P3/P1PP1PPP/BNRBKNRQ b KQkq - 
 8b n r b k   r q *
 7p p p p p p p p 
 6        n       
 5                
 4                
 3  P     P       
 2P   P P   P P P 
 1B N R B K N R Q 
  a b c d e f g h 
#&#91;Chess&#93; 0b &#40;f&#41;>O-O
 8b n r b   r k q 
 7p p p p p p p p 
 6        n       
 5                
 4                
 3  P     P       
 2P   P P   P P P 
 1B N R B K N R Q *
  a b c d e f g h 
#&#91;Chess&#93; 1w &#40;f&#41;>
Michel wrote: BTW Sjaak prints so much info during start up that it exposed a buffer overflow in icsdrone :-)
Really? All it should print is a version string, a help message, the board and a prompt.
Although I suppose that if you expect to receive in the order of a single line at a time it could overflow the buffer... :)
If you start directly in CECP mode ("sjaakii -xboard") it will not print the board. You still get the version and help message though.

EDIT: I tested both "bnrbk1rq/pppppppp/4n3/8/8/1P2P3/P1PP1PPP/BNRBKNRQ b CGcg -" and "bnrbk1rq/pppppppp/4n3/8/8/1P2P3/P1PP1PPP/BNRBKNRQ b KQkq -", both seem to work here.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Ok thanks. I'll investigate more on my side.

EDIT: It does work on the command line too for me. So probably icsdrone is at fault in some way... :-(
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Question about Sjaak

Post by bob »

Michel wrote:While testing icsdrone with Sjaak it appears that Sjaak rejects O-O as castling notation during fisherandom. I think this is incorrect according to

https://www.gnu.org/software/xboard/engine-intf.html#8 (section "MOVE").
Fri Apr 1 12:46:02 2016:DEBUG:ics->icsdrone: <12> bnrb-rkq pppppppp ----n--- -------- -------- -P--P--- P-PP-PPP BNRBKNRQ W -1 0 0 0 0 0 1061 GnuCheese dado53 1 2 12 39 39 138 143 3 o-o (0:01) O-O 0\015\012
Fri Apr 1 12:46:02 2016:DEBUG:icsdrone->engine: time 13800\012otim 14300\012
Fri Apr 1 12:46:02 2016:INFO:Move from ICS: O-O O-O
Fri Apr 1 12:46:02 2016:DEBUG:icsdrone->engine: O-O\012
Fri Apr 1 12:46:02 2016:DEBUG:engine->icsdrone: Error (Illegal move or unknown command): O-O\012
Note that the ICS board gives the situation _after_ the castling move.
What is that character following the O-O? (012) In C that would be octal making it a 0x'0a' or "\n".

That's the normal unix end of line character (where windows likes a CR/LF pair to end the line.) That is normally removed during input parsing, but since it is showing that each time it mentions the O-O move, that looks wrong.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

bob wrote: What is that character following the O-O? (012) In C that would be octal making it a 0x'0a' or "\n".

That's the normal unix end of line character (where windows likes a CR/LF pair to end the line.) That is normally removed during input parsing, but since it is showing that each time it mentions the O-O move, that looks wrong.
You know, that is a good point. If there is an extra character, the string would not match the move string and the move would be rejected.
Question is how the extra character would get there. I use fgets to get the string (or readline when reading from a terminal) and then trim whitespace and newline from the end of the string...
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Well it happens only with O-O or O-O-O. That suggests it is not a silly white space issue.

The \012 is just a textual representation (for the log file) of a newline (^J), the line separator on Linux. It is natural that icsdrone sends this to the engine and also natural that the engine sends it back.

I noticed now that the phenomenon does not always happen. Sometimes the O-O is accepted as legal.

I will try to get to the bottom of this, but right now I am bit busy.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
User avatar
hgm
Posts: 27815
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Question about Sjaak

Post by hgm »

Michel wrote:I noticed now that the phenomenon does not always happen. Sometimes the O-O is accepted as legal.
Then it is more likely to be an issue with castling rights than with the move encoding.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

It may be useful to run SjaakII with the -log argument so that it does its own logging. Mostly this will just record the input and output, but it makes it easy to see what the engine things it gets as input (at least for me).
I don't think it logs the FEN of the current position at the start of the search, but this might actually be useful information to have, so perhaps I should add that.