Could anyone make me a Windows compile...?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Could anyone make me a Windows compile...?

Post by Evert »

mar wrote: Now back to the problem, I think it's a (serious?) bug in Sjaak.
What do you think this expression evaluates to:

Code: Select all

&#40;uint64_t&#41;1 << 125
That is indeed a bug. I can't think off the top of my head where that code occurs though, and without that context it's hard to say what the correct fix might be (I haven't looked at your source archive yet).
Off the top of my head, only bitboards should be shifted by an arbitrary large amount, and they should know their size and assert on that.
At the end of evaluate.h I left a debug code for you (#if 0 for now) so that you can trace the problem.
But probably that's not necessary - best would be to put an assert in bitboard.h.
Indeed.
(the "fixes" in bitboard.h are marked with comments and FIXMEs)
I'm not sure if/how this would affect performance and/or variants that use 128-bit bitboards...
Well, "test movegen" tests (some) variants that use 128 bit bitboards, so if that passes it should be ok...
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Could anyone make me a Windows compile...?

Post by mar »

Evert wrote:Well, "test movegen" tests (some) variants that use 128 bit bitboards, so if that passes it should be ok...
test movegen passes.
So I played a couple of variants in Winboard and Sjaak seemed fine (except that in Gothic it was outsearched by Fairy-max, not sure if this is ok).
In Seirawan game, Fairy-max (4.8S) played an illegal move :shock:
I think it's because it expected having put hawk/elephant but Winboard somehow didn't notice it. Maybe I'm using outdated Winboard (4.7.2).
Anyway I guess hgm can grab the compiles (each under 1M and both compress to 800kb using zip).
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Could anyone make me a Windows compile...?

Post by hgm »

mar wrote:In Seirawan game, Fairy-max (4.8S) played an illegal move :shock:
This problem has been solved in later versions (4.8V is included with the latest WinBoard install). It was due to a bug in printing the promotion character, (which does double duty as indicating the gated piece in the WB protocol move notation), so that WinBoard would not recognize it as part of the move, and consider the move as a non-gating. Later moves with the gated piece would then be rejected as illegal.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Could anyone make me a Windows compile...?

Post by hgm »

Both the 32-bit and 64-bit icc compile seem to work fine (for min-Shogi). Very many thanks for this!

One unrelated issue: Sjaak II did a 4-fold repeat with Sente:

Code: Select all

&#91;Event "Computer Chess Game"&#93;
&#91;Site "ONTWIKKELLAPTOP"&#93;
&#91;Date "2015.01.02"&#93;
&#91;Round "-"&#93;
&#91;White "Sjaak II unknown revision "&#93;
&#91;Black "Shokidoki tori3"&#93;
&#91;Result "0-1"&#93;
&#91;TimeControl "1200"&#93;
&#91;Variant "shogi"&#93;
&#91;FEN "rbsgk/4p/5/P4/KGSBR&#91;-&#93; w 0 1"&#93;
&#91;SetUp "1"&#93;

&#123;--------------
r b s g k
. . . . p
. . . . .
P . . . .
K G S B R
white to play
--------------&#125;
1. Sd2 &#123;+0.23/15&#125; Sb4 &#123;+0.40/15 48&#125; 2. Gb2 &#123;+0.00/16 52&#125; Bc4 &#123;+0.32/16 38&#125;
3. Bc2 &#123;+0.00/15 57&#125; Gd4 &#123;+0.28/16 47&#125; 4. Rd1 &#123;+0.00/14 41&#125; Rd5 5. Rb1
&#123;-0.08/15 56&#125; Ra5 &#123;+0.40/15 25&#125; 6. Re1 &#123;+0.20/14 31&#125; Kd5 &#123;+0.56/15 0.5&#125; 7.
Rd1 &#123;+0.75/13 33&#125; Be2 &#123;+1.08/15 1&#58;18&#125; 8. Re1 &#123;+0.87/15 36&#125; Bc4
&#123;+0.44/16 38&#125; 9. Kb1 &#123;-0.12/12 27&#125; Ke5 &#123;+0.76/14 37&#125; 10. Rd1 &#123;+0.22/12 17&#125;
Be2 &#123;+0.84/14 2.5&#125; 11. Re1 &#123;+0.77/14 23&#125; Bc4 &#123;+1.84/13 24&#125; 12. Bd1
&#123;-1.02/13 38&#125; Bd5 &#123;+2.40/14 29&#125; 13. Bc2 &#123;+0.04/14 31&#125; Bc4 &#123;+1.80/14 18&#125; 14.
Kc1 &#123;-0.55/12 28&#125; Rc5 &#123;+1.84/14 39&#125; 15. Kb1 &#123;+0.00/13 33&#125; Ra5 &#123;+2.96/14 44&#125;
&#123;Xboard adjudication&#58; repetition&#125; 0-1
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Could anyone make me a Windows compile...?

Post by hgm »

OK, I updated the WinBoard mini-Shogi package with the latest versions of Lima and Shokidoki,, and added Sjaak II.

http://hgm.nubati.net/miniShogi.html

direct download link:

http://hgm.nubati.net/WinBoard-mini.exe

Btw, it seems that I won the 'originality prize' associated with the 8th UEC Cup, for the development of WinBoard as mini-Shogi interface.
:shock:

http://minerva.cs.uec.ac.jp/~uec55shogi ... 2%E7%B2%F1
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Could anyone make me a Windows compile...?

Post by Henk »

Perhaps you can only win such a tournament if you add expert knowledge to your engine. Did you use a generic engine without extra knowledge ?

For instance Komodo also has the relatively best chess player in their team.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Could anyone make me a Windows compile...?

Post by hgm »

The problem with mini-Shogi is that the knowledge might not exist. The game was invented only in recent times, and was never played by millions of people, or by professional (min-Shogi) players.

They have not published the games yet, so I have no idea why Shokidoki lost to 1/128 Rigan in the 8th UEC Cup. (Beating it was the only thing required to win the cup.) On several occations it did beat 1/128 Rigan, which got it the gold medal in the 2013 Computer Olympiad. So it is not impossible to win with very little knowledge. (Of course it does have terms like piece values, PST and King safety, but they are all my own guesses.)
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Could anyone make me a Windows compile...?

Post by Evert »

mar wrote: Now back to the problem, I think it's a (serious?) bug in Sjaak.
What do you think this expression evaluates to:

Code: Select all

&#40;uint64_t&#41;1 << 125
Problem is the CPU instruction on x64 does masking by 63 and obviously gcc in 32-bit mode too.
However Microsoft CRT does no masking in 32-bit emulation and hence the "problem".
(this is why I advocate compiling with different compilers at different platforms, because sometimes it can help to catch bugs)

At the end of evaluate.h I left a debug code for you (#if 0 for now) so that you can trace the problem.
But probably that's not necessary - best would be to put an assert in bitboard.h.
(the "fixes" in bitboard.h are marked with comments and FIXMEs)
I'm not sure if/how this would affect performance and/or variants that use 128-bit bitboards...
I'm going through the changes now to pull them into my repository (with some minor changes, mostly formatting).

This is a somewhat serious issue though.

Code: Select all

       inline void set&#40;int bit&#41; &#123;
+                // not sure at all if the following "fix" holds for 128-bit bitboards
+                bit &= sizeof&#40;kind&#41;*8-1;
          //printf&#40;"%d\n", bit&#41;;
          bb |= ((&#40;kind&#41;1&#41; << bit&#41;;
       &#125;
       inline void reset&#40;int bit&#41; &#123;
+                // FIXME&#58; a value of 125 made it as bit for 64-bit bitboard
+                // not sure at all if the following "fix" holds for 128-bit bitboards
+                bit &= sizeof&#40;kind&#41;*8-1;
          bb &= ~((&#40;kind&#41;1&#41; << bit&#41;;
       &#125;
       bool test&#40;int bit&#41; const &#123;
-         return bb & ((&#40;kind&#41;1&#41; << bit&#41;;
+                // not sure at all if the following "fix" holds for 128-bit bitboards
+                bit &= sizeof&#40;kind&#41;*8-1;
+         return &#40;bb & ((&#40;kind&#41;1&#41; << bit&#41;) != 0;
       &#125;
The expected behaviour for out-of-bound bits (which automatically means an off-the-board square) is for set() and reset() to do nothing and for test() to always return false (or be undefined, see below), however that's not what the code here does: it will instead manipulate a random bit on the board.

More to the point, however: none of these functions should ever be called on out-of-board squares. I'll put in place asserts instead and see if I can trigger them locally.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Could anyone make me a Windows compile...?

Post by Evert »

Another question:

In timer.c, you made the following change:

Code: Select all

-#include <unistd.h>
+#include "unistd_wrapper.h"
 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199309L && defined _POSIX_TIMERS && _POSIX_TIMERS>0 && defined _POSIX_MONOTONIC_CLOCK
 #define USE_CLOCK_GETTIME
 #include <time.h>
+#elif defined _MSC_VER
+#      define USE_GETTICKCOUNT
+#      include <windows.h>
+#      undef min
+#      undef max
 #else
-#include <sys/time.h>
+#include "sys_time_wrapper.h"
 #endif
with sys_time_wrapper as

Code: Select all

#if defined _MSC_VER
#else
#	include <sys/time.h>
#endif
However, as far as I can see that file should only ever be included if the "elif defined _MSC_VER" does not trigger, so the following should do the exact same thing:

Code: Select all

#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199309L && defined _POSIX_TIMERS && _POSIX_TIMERS>0 && defined _POSIX_MONOTONIC_CLOCK
#define USE_CLOCK_GETTIME
#include <time.h>
#elif defined _MSC_VER
#	define USE_GETTICKCOUNT
#	include <windows.h>
#	undef min
#	undef max
#else
#include <sys/time.h>
#endif
correct?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Could anyone make me a Windows compile...?

Post by Evert »

hgm wrote:The problem with mini-Shogi is that the knowledge might not exist. The game was invented only in recent times, and was never played by millions of people, or by professional (min-Shogi) players.

They have not published the games yet, so I have no idea why Shokidoki lost to 1/128 Rigan in the 8th UEC Cup. (Beating it was the only thing required to win the cup.) On several occations it did beat 1/128 Rigan, which got it the gold medal in the 2013 Computer Olympiad. So it is not impossible to win with very little knowledge. (Of course it does have terms like piece values, PST and King safety, but they are all my own guesses.)
I was rather pleased with where SjaakII ended up in the ranking - especially since it managed to beat both 1/128 Rigan and Shokidoki.

SjaakII probably has less knowledge than Shokidoki does, certainly knowledge that is specific to mini-Shogi. However, the game may be sufficiently tactical that it doesn't matter so much...