Question about Sjaak

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Michel wrote:
Doesn't it simply choke on the '+' here. (Illegal promotion; Bishops do not promote to Dragon Horse in variant normal...)
Yes that's it! Although I do not see the connection with promotion. An appended + is legal in SAN no?

You seem to be sending SAN, which seems a protocol violation in itself.


I agree. It seems sjaak is indeed not to blame. It does not advertize that it understands SAN so it is not required to parse it....

A problem with icsdrone is that it has no chess knowledge. So it has to rely on the ics for move lists. Unfortunately ICC only seems to provide move lists in SAN (I would be glad to learn otherwise). Currently icsdrone assumes by default that the engine understands SAN. There is an option to turn that off but then it cannot use move lists, with the usual caveats for adjourned games (this is a minor issue really).

I have a question: what is the reference for a crazyhouse FEN?
"+" is a promotion suffix in Shogi variants.
In fact, SjaakII does understand SAN, with one exception: the + at the end of a checking move. I could just make it ignore that.
The reason it doesn't advertise that it understands SAN is that it does this purely for convenience when used from the commandline, not for interaction with another program. If you type "longmoves" it will list all legal moves in the current position in the different formats it understands. I sortof want to add "RxQ" style to that, but this is a feature with about 0 demand...
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Evert wrote: Yes, but I chop it off. The only thing I can think of is that there are two of them and I only chop off the last one, rather than the first one. Seems unlikely as I would normally use strstr to look for "\n", but I have to check the source.
Actually, I did do that:

Code: Select all

static inline char *chomp(char *s)
{
   char *p;
   p = strstr(s, "\n");
   if (p) *p = '\0';
   return s;
}
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Ok, I made it ignore a trailing "+" in the input if it fails to find a matching move in the move list; source is here: http://www.eglebbk.dds.nl/program/downl ... src.tar.gz
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Evert wrote:Ok, I made it ignore a trailing "+" in the input if it fails to find a matching move in the move list; source is here: http://www.eglebbk.dds.nl/program/downl ... src.tar.gz
Thanks!
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Here is another potential bug.

Consider the crazyhouse FEN (generated by sjaak's fen command)

2kr1b1r/p1p1ppp1/2q1b1pn/2p1P3/2PpN3/3P2NP/PP3PP1/R1BQ1RK1[Bn] b - c3 0 16

After dxc3 (an e.p. move) sjaak claims that black's holdings contain two knights.

ICC disagrees and claims black's holdings are NP (which is correct IMHO).
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
mar
Posts: 2552
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Question about Sjaak

Post by mar »

Evert wrote:
Evert wrote: Yes, but I chop it off. The only thing I can think of is that there are two of them and I only chop off the last one, rather than the first one. Seems unlikely as I would normally use strstr to look for "\n", but I have to check the source.
Actually, I did do that:

Code: Select all

static inline char *chomp(char *s)
{
   char *p;
   p = strstr(s, "\n");
   if (p) *p = '\0';
   return s;
}
Ah I see. Unfortunately on Windows EOL is usually "\r\n";
I'd probably chop any trailing '\r' or '\n' just to be sure; still "\n" is "\012" so the code you posted should handle that. Strange.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Michel wrote:Here is another potential bug.

Consider the crazyhouse FEN (generated by sjaak's fen command)

2kr1b1r/p1p1ppp1/2q1b1pn/2p1P3/2PpN3/3P2NP/PP3PP1/R1BQ1RK1[Bn] b - c3 0 16

After dxc3 (an e.p. move) sjaak claims that black's holdings contain two knights.

ICC disagrees and claims black's holdings are NP (which is correct IMHO).
Argh!
You don't want to know how often I've fixed a bug similar to this. There is some unfortunate interaction between different variants that makes it easy for a fix in one variant to break another. I can reproduce the problem, so it shouldn't be hard to fix. Then I'll go back and add the offending positions in the different variants (including this one) to the movegen test (if I haven't already for some of the others).
Thanks for reporting!
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

mar wrote:
Evert wrote:
Evert wrote: Yes, but I chop it off. The only thing I can think of is that there are two of them and I only chop off the last one, rather than the first one. Seems unlikely as I would normally use strstr to look for "\n", but I have to check the source.
Actually, I did do that:

Code: Select all

static inline char *chomp(char *s)
{
   char *p;
   p = strstr(s, "\n");
   if (p) *p = '\0';
   return s;
}
Ah I see. Unfortunately on Windows EOL is usually "\r\n";
I'd probably chop any trailing '\r' or '\n' just to be sure; still "\n" is "\012" so the code you posted should handle that. Strange.
It's been ages since I've worked on a Windows system, but from what I remember it does some funky conversions for "text mode" that translates "\n" to "\r\n" when appropriate and vice-versa that makes using "\n" when matching a string ok, but matching the character '\n' error prone (ie, strstr(str, "\n") != strchr(str, '\n')). It's been a while since I thought about this though, so I may mis-remember.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Question about Sjaak

Post by Evert »

Evert wrote: Argh!
You don't want to know how often I've fixed a bug similar to this. There is some unfortunate interaction between different variants that makes it easy for a fix in one variant to break another. I can reproduce the problem, so it shouldn't be hard to fix. Then I'll go back and add the offending positions in the different variants (including this one) to the movegen test (if I haven't already for some of the others).
Thanks for reporting!
Ok, fixed it: http://www.eglebbk.dds.nl/program/downl ... src.tar.gz
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

Re: Question about Sjaak

Post by Michel »

Ok it's running.

I am now logging the fen on icsdrone's side. Since sjaak logs the fen on his side when it declares a move illegal, I should be able to figure out what goes on with O-O.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.