Progress On Bricabrac

Discussion of chess software programming and technical issues.

Moderators: hgm, chrisw, Rebel

Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

More clues. I added some printf statements to the root search.

Code: Select all

void RootSearch(Thread* t, Move* m, s32 alpha, s32 beta, s32 depth, u64 n) {
  s32 mi, j;
  Move* mov;

  for (mi = 0; mi < n; mi++) {
    mov = m + mi;
    if (mov->fs == pvs[0][0].fs && mov->ts == pvs[0][0].ts && mov->type == pvs[0][0].type) {
      mov->score = 1000000;
      break;
    }
  }

  SortRoot(t, move, n);

  for (mi = 0; mi < n; mi++) {
    mov = m + mi;
    MakeMove(t, mov);
    mov->score = -Search(t, m + n, -beta, -alpha, depth - 1);
    TakeBack(t, mov);
    if (mov->score == -ILLEGAL) {
      printf("ILLEGAL\n"); // <-----------------------------------------------------------
      continue;
    }
    if (mov->score > alpha) {
      printf("\nalpha = %i\n", alpha); // <-----------------------------------------------
      alpha = mov->score;
      printf("alpha = %i\n\n", alpha); // <-----------------------------------------------
      bestMove = *mov;
      pvs[ply][ply] = *mov;
      for (j = ply + 1; j < pvl[ply + 1]; j++) {
        pvs[ply][j] = pvs[ply + 1][j];
      }
      pvl[ply] = pvl[ply + 1];
    }
    if (clock() > end) break;
  }
}
And ran the following. And I am totally baffled by it.

r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R

Enter Command(w):
st 30
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R

Enter Command(w):
go

Begin Depth 1

alpha = -32767
alpha = 35

1 35 0 20 d2d4

Begin Depth 2

alpha = -32767
alpha = 0


alpha = 0
alpha = 1

2 1 0 106 g1f3 d7d5

Begin Depth 3

alpha = -32767
alpha = 35

3 35 0 682 g1f3 g8f6 d2d4

Begin Depth 4

alpha = -32767
alpha = 0

4 0 0 4159 g1f3 g8f6 d2d4 d7d5

Begin Depth 5

alpha = -32767
alpha = 33

5 33 0 19237 g1f3 g8f6 d2d4 d7d5 b1c3

Begin Depth 6

alpha = -32767
alpha = 1


alpha = 1
alpha = 5

6 5 1 72690 e2e4 b8c6 b1c3 e7e5 c3d5 g8f6

Begin Depth 7

alpha = -32767
alpha = 17


alpha = 17
alpha = 28

7 28 1 135203 d2d4 b8c6 g1f3 d7d5 b1c3 g8f6 c1e3

Begin Depth 8

alpha = -32767
alpha = 3


alpha = 3
alpha = 10


alpha = 10
alpha = 14

8 14 4 396105 e2e4 b8c6 d2d4 d7d5 e4d5 d8d5 g1f3 g8f6

Begin Depth 9

alpha = -32767
alpha = 29

9 29 9 1107427 e2e4 b8c6 g1f3 g8f6 b1c3 d7d5 e4d5 f6d5 d2d4

Begin Depth 10

alpha = -32767
alpha = 17

10 17 43 4743732 e2e4 b8c6 g1f3 g8f6 b1c3 d7d5 e4d5 f6d5 c3d5 d8d5

Begin Depth 11

alpha = -32767
alpha = 26

11 26 160 21601527 e2e4 e7e5 g1f3 g8f6 b1c3 b8c6 f1d3 f8d6 e1g1 h8f8 h2h3

Begin Depth 12

alpha = -32767
alpha = 19

12 19 938 106447777 e2e4 e7e5 b1c3 g8f6 g1f3 b8c6 f1c4 f8b4 c3d5 b4d6 d2d3 h8f8

Begin Depth 13

alpha = -32767
alpha = 18


Move Played: E2E4 Score: 19
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . P . . .
. . . . . . . .
P P P P . P P P
R N B Q K B N R

Enter Command(b):
setboard 8/8/P2k3p/7P/4PKP1/1BP5/8/8 b - - 0 53
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
st 1
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
go

Begin Depth 1
ILLEGAL
ILLEGAL
ILLEGAL

alpha = -32767
alpha = -824

1 -824 0 8 d6c5

Begin Depth 2

alpha = -32767
alpha = -908

ILLEGAL
ILLEGAL
ILLEGAL
2 -908 0 59 d6c5 a6a7

Begin Depth 3

alpha = -32767
alpha = -1521


alpha = -1521
alpha = -940

ILLEGAL
ILLEGAL
ILLEGAL
3 -940 0 358 d6c6 a6a7 c6b7

Begin Depth 4

alpha = -32767
alpha = -888

ILLEGAL
ILLEGAL
ILLEGAL
4 -888 1 1480 d6c6 f4e5 c6b6 b3c4

Begin Depth 5

alpha = -32767
alpha = -864

ILLEGAL
ILLEGAL
ILLEGAL
5 -864 1 2934 d6c6 f4e5 c6b6 b3c4 b6c5

Begin Depth 6

alpha = -32767
alpha = -900

ILLEGAL
ILLEGAL
ILLEGAL
6 -900 2 8015 d6c6 f4e5 c6c7 e5e6 c7b6 b3c4

Begin Depth 7

alpha = -32767
alpha = -900

ILLEGAL
ILLEGAL
ILLEGAL
7 -900 2 13850 d6c6 f4e5 c6b6 b3c4 b6a7 e5e6 a7b6

Begin Depth 8

alpha = -32767
alpha = -935

ILLEGAL
ILLEGAL
ILLEGAL
8 -935 2 53391 d6c6 b3c4 c6b6 f4f5 b6a7 f5g6 a7b6 g6h6

Begin Depth 9

alpha = -32767
alpha = -1464

ILLEGAL
ILLEGAL
ILLEGAL
9 -1464 3 83392 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 10
ILLEGAL
ILLEGAL
ILLEGAL
10 -32767 6 717942 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 11
ILLEGAL
ILLEGAL
ILLEGAL
11 -32767 19 2673772 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 12
ILLEGAL
ILLEGAL
ILLEGAL
12 -32767 39 7184219 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 13
resign
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

So I changed the printf to print the black kings moves. And at depth 10 they all came back as mate in zero or ILLEGAL.
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R

Enter Command(w):
setboard 8/8/P2k3p/7P/4PKP1/1BP5/8/8 b - - 0 53
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
st 1
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
go

Begin Depth 1
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
fs 43 ts 44 score -32768
fs 43 ts 34 score -824
fs 43 ts 52 score -824
fs 43 ts 51 score -824
fs 43 ts 42 score -824
fs 43 ts 50 score -824
1 -824 0 8 d6c5

Begin Depth 2
fs 43 ts 34 score -908
fs 43 ts 52 score -908
fs 43 ts 51 score -908
fs 43 ts 42 score -908
fs 43 ts 50 score -908
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
2 -908 0 59 d6c5 a6a7

Begin Depth 3
fs 43 ts 34 score -1521
fs 43 ts 52 score -1521
fs 43 ts 51 score -1521
fs 43 ts 42 score -940
fs 43 ts 50 score -940
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
3 -940 1 358 d6c6 a6a7 c6b7

Begin Depth 4
fs 43 ts 42 score -888
fs 43 ts 50 score -888
fs 43 ts 51 score -888
fs 43 ts 34 score -888
fs 43 ts 52 score -888
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
4 -888 1 1480 d6c6 f4e5 c6b6 b3c4

Begin Depth 5
fs 43 ts 42 score -864
fs 43 ts 50 score -864
fs 43 ts 51 score -864
fs 43 ts 34 score -864
fs 43 ts 52 score -864
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
5 -864 1 2934 d6c6 f4e5 c6b6 b3c4 b6c5

Begin Depth 6
fs 43 ts 42 score -900
fs 43 ts 50 score -900
fs 43 ts 51 score -900
fs 43 ts 34 score -900
fs 43 ts 52 score -900
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
6 -900 2 8015 d6c6 f4e5 c6c7 e5e6 c7b6 b3c4

Begin Depth 7
fs 43 ts 42 score -900
fs 43 ts 50 score -900
fs 43 ts 51 score -900
fs 43 ts 34 score -900
fs 43 ts 52 score -900
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
7 -900 2 13850 d6c6 f4e5 c6b6 b3c4 b6a7 e5e6 a7b6

Begin Depth 8
fs 43 ts 42 score -935
fs 43 ts 50 score -935
fs 43 ts 51 score -935
fs 43 ts 34 score -935
fs 43 ts 52 score -935
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
8 -935 3 53391 d6c6 b3c4 c6b6 f4f5 b6a7 f5g6 a7b6 g6h6

Begin Depth 9
fs 43 ts 42 score -1464
fs 43 ts 50 score -1464
fs 43 ts 51 score -1464
fs 43 ts 34 score -1464
fs 43 ts 52 score -1464
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
9 -1464 4 83392 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 10
fs 43 ts 42 score -32767
fs 43 ts 50 score -32767
fs 43 ts 51 score -32767
fs 43 ts 34 score -32767
fs 43 ts 52 score -32767
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
10 -32767 7 717942 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 11
fs 43 ts 42 score -32767
fs 43 ts 50 score -32767
fs 43 ts 51 score -32767
fs 43 ts 34 score -32767
fs 43 ts 52 score -32767
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
11 -32767 20 2673772 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 12
fs 43 ts 42 score -32767
fs 43 ts 50 score -32767
fs 43 ts 51 score -32767
fs 43 ts 34 score -32767
fs 43 ts 52 score -32767
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
12 -32767 41 7184219 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 13
fs 43 ts 42 score -32767
fs 43 ts 50 score -32767
fs 43 ts 51 score -32767
resign
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

But perfectly okay in debug mode. Any ideas?
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R

Enter Command(w):
setboard 8/8/P2k3p/7P/4PKP1/1BP5/8/8 b - - 0 53
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
st 3
. . . . . . . .
. . . . . . . .
P . . k . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(b):
go

Begin Depth 1
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
fs 43 ts 44 score -32768
fs 43 ts 34 score -824
fs 43 ts 52 score -824
fs 43 ts 51 score -824
fs 43 ts 42 score -824
fs 43 ts 50 score -824
1 -824 0 8 d6c5

Begin Depth 2
fs 43 ts 34 score -908
fs 43 ts 52 score -908
fs 43 ts 51 score -908
fs 43 ts 42 score -908
fs 43 ts 50 score -908
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
2 -908 0 59 d6c5 a6a7

Begin Depth 3
fs 43 ts 34 score -1521
fs 43 ts 52 score -1521
fs 43 ts 51 score -1521
fs 43 ts 42 score -940
fs 43 ts 50 score -940
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
3 -940 0 358 d6c6 a6a7 c6b7

Begin Depth 4
fs 43 ts 42 score -888
fs 43 ts 50 score -888
fs 43 ts 51 score -888
fs 43 ts 34 score -888
fs 43 ts 52 score -888
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
4 -888 1 1480 d6c6 f4e5 c6b6 b3c4

Begin Depth 5
fs 43 ts 42 score -864
fs 43 ts 50 score -864
fs 43 ts 51 score -864
fs 43 ts 34 score -864
fs 43 ts 52 score -864
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
5 -864 1 2934 d6c6 f4e5 c6b6 b3c4 b6c5

Begin Depth 6
fs 43 ts 42 score -900
fs 43 ts 50 score -900
fs 43 ts 51 score -900
fs 43 ts 34 score -900
fs 43 ts 52 score -900
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
6 -900 2 8015 d6c6 f4e5 c6c7 e5e6 c7b6 b3c4

Begin Depth 7
fs 43 ts 42 score -900
fs 43 ts 50 score -900
fs 43 ts 51 score -900
fs 43 ts 34 score -900
fs 43 ts 52 score -900
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
7 -900 2 13850 d6c6 f4e5 c6b6 b3c4 b6a7 e5e6 a7b6

Begin Depth 8
fs 43 ts 42 score -935
fs 43 ts 50 score -935
fs 43 ts 51 score -935
fs 43 ts 34 score -935
fs 43 ts 52 score -935
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
8 -935 4 55104 d6c6 b3c4 c6b6 f4f5 b6a7 f5g6 a7b6 g6h6

Begin Depth 9
fs 43 ts 42 score -1464
fs 43 ts 50 score -1464
fs 43 ts 51 score -1464
fs 43 ts 34 score -1464
fs 43 ts 52 score -1464
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
9 -1464 5 85105 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5

Begin Depth 10
fs 43 ts 42 score -1110
fs 43 ts 50 score -1110
fs 43 ts 51 score -1110
fs 43 ts 34 score -1110
fs 43 ts 52 score -1110
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
10 -1110 14 372819 d6c6 b3c4 c6b6 e4e5 b6c6 e5e6 c6c7 a6a7 c7b7 e6e7

Begin Depth 11
fs 43 ts 42 score -1478
fs 43 ts 50 score -1478
fs 43 ts 51 score -1478
fs 43 ts 34 score -1478
fs 43 ts 52 score -1478
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
11 -1478 47 1464831 d6c6 e4e5 c6b6 b3f7 b6a6 e5e6 a6b6 e6e7 b6c6 f4e5 c6c5

Begin Depth 12
fs 43 ts 42 score -1512
fs 43 ts 50 score -1512
fs 43 ts 51 score -1512
fs 43 ts 34 score -1512
fs 43 ts 52 score -1512
fs 43 ts 44 score -32768
fs 43 ts 36 score -32768
fs 43 ts 35 score -32768
12 -1512 190 6586643 d6c6 e4e5 c6b6 e5e6 b6c6 a6a7 c6b7 e6e7 b7a7 e7e8q a7b6 f4e5

Begin Depth 13
fs 43 ts 42 score -32767

Move Played: D6C6 Score: -1512
. . . . . . . .
. . . . . . . .
P . k . . . . p
. . . . . . . P
. . . . P K P .
. B P . . . . .
. . . . . . . .
. . . . . . . .

Enter Command(w):
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Progress On Bricabrac

Post by Sven »

Mike Sherwin wrote: Thu Apr 29, 2021 2:58 am I goofed that up. Let me try again.

Arena running the debug build.
FEN: 8/8/P1k4p/7P/4PKP1/1BP5/8/8 w - - 1 54

Bricabrac:
1 00:00 8 8 -8.24 d6c5
2 00:00 59 59 -9.08 d6c5 a6a7
3 00:00 352 352 -9.40 d6c6 a6a7 c6b7
4 00:00 1k 1k -8.88 d6c6 f4e5 c6b6 b3c4
5 00:00 3k 3k -8.64 d6c6 f4e5 c6b6 b3c4 b6c5
6 00:00 8k 8k -9.00 d6c6 f4e5 c6c7 e5e6 c7b6 b3c4
7 00:00 14k 14k -9.00 d6c6 f4e5 c6b6 b3c4 b6a7 e5e6 a7b6
8 00:00 55k 5,510k -9.35 d6c6 b3c4 c6b6 f4f5 b6a7 f5g6 a7b6 g6h6
9 00:00 85k 4,255k -14.64 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5
10 00:00 373k 3,728k -11.10 d6c6 b3c4 c6b6 e4e5 b6c6 e5e6 c6c7 a6a7 c7b7 e6e7

Arena running the release build.
FEN: 8/8/P2k3p/7P/4PKP1/1BP5/8/8 b - - 0 53

Bricabrac:
1 00:00 8 8 -8.24 d6c5
2 00:00 59 59 -9.08 d6c5 a6a7
3 00:00 352 352 -9.40 d6c6 a6a7 c6b7
4 00:00 1k 1k -8.88 d6c6 f4e5 c6b6 b3c4
5 00:00 3k 3k -8.64 d6c6 f4e5 c6b6 b3c4 b6c5
6 00:00 8k 8k -9.00 d6c6 f4e5 c6c7 e5e6 c7b6 b3c4
7 00:00 14k 14k -9.00 d6c6 f4e5 c6b6 b3c4 b6a7 e5e6 a7b6
8 00:00 53k 53k -9.35 d6c6 b3c4 c6b6 f4f5 b6a7 f5g6 a7b6 g6h6
9 00:00 83k 83k -14.64 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5
10 00:00 718k 23,931k -M0 d6c6 a6a7 c6b7 e4e5 b7a7 e5e6 a7b6 e6e7 b6c5
You tested two different positions ... Does not explain the -M0 but is also not suitable for a comparison ...
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Progress On Bricabrac

Post by Sven »

Mike Sherwin wrote: Thu Apr 29, 2021 8:08 am But perfectly okay in debug mode. Any ideas?
I would not care too much about debug vs. release. There is a bug, probably caused by undefined behaviour which modern compilers see as an invitation to generate code as they like. So don't think about the compiler but about the bug.

What does -32767 mean for a root move? How does a subtree search return a score of +32767 which is then negated in the parent?

In depth 10 the search has visited >600000 nodes so a lot happened in the subtrees of the five legal moves for Black. I would carefully analyze all data after depth 8 returned, and compare that to the state after depth 9. Anything corrupted that caused depth 10 to do bogus?

I would also look at the sub-PVs of the root moves.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

Sven wrote: Thu Apr 29, 2021 9:19 am
Mike Sherwin wrote: Thu Apr 29, 2021 8:08 am But perfectly okay in debug mode. Any ideas?
I would not care too much about debug vs. release. There is a bug, probably caused by undefined behaviour which modern compilers see as an invitation to generate code as they like. So don't think about the compiler but about the bug.

What does -32767 mean for a root move? How does a subtree search return a score of +32767 which is then negated in the parent?

In depth 10 the search has visited >600000 nodes so a lot happened in the subtrees of the five legal moves for Black. I would carefully analyze all data after depth 8 returned, and compare that to the state after depth 9. Anything corrupted that caused depth 10 to do bogus?

I would also look at the sub-PVs of the root moves.
32767 is INFINITY. All it means is that none of the legal root moves is returning a score > alpha.
Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

I found it, I found it! :D
And it is a compiler bug and not a coding bug like everyone tried to convince me of!! :P
I turned off whole program optimization and the bug just simply disappeared!!! :D :D :D
Mike Sherwin
Posts: 925
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Progress On Bricabrac

Post by Mike Sherwin »

It has been a long couple of days. I've done enough testing to confirm that the bug is really gone. What a relief. Also 3-fold repetition is working. But, at times it seems a little flaky. However, the number of draws is greatly reduced against TSCP. On the other hand when it becomes flaky it is causing some losses. Hopefully tomorrow it will be fixed. gn
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Progress On Bricabrac

Post by Sven »

Good news, Mike!

Hard to believe, though, that it is actually a compiler bug ... For me it still looks like there is some undefined behaviour causing the compiler to do "undesired" optimizations, unless you prevent him to do so by switching optimizations off.

A possible example might be the use of = where == was intended.

Code: Select all

int a = complex_calculation(b, c, d);
if (a = 42) ...
This may cause the compiler to assume that b, c and d are "unused", and he might even throw away the function complex_calculation() if noone else uses it, which he might find out during "whole program optimization". Not sure if you would see a warning about that ...
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
User avatar
hgm
Posts: 28205
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Progress On Bricabrac

Post by hgm »

My approach to debugging is to have a number of conditional print statements in the code: if(PATH) printf("%d:%d ...", ply, depth, ...);. In a 'release version' PATH is #defined as 0, which makes the optimizer delete them. If I want to debug I redefine PATH in steps, starting with ply == 0 (to get diagnosics from he root), and then zooming in onto the problem through ply==0 || path[0]==MOVE0 && (ply==1 || path[1]==MOVE1 && (ply==2 ...)) to limit the printed info to nodes along the path specified by MOVE0, MOVE1 etc.

In general I use only a single such print satement, right after UnMake(), to print the move (text and intenral hex encoding), score, and best score. If I am debuging a crash I put an identical print statement before MakeMove(), making sure it is crash-proof (printing to stderr or using fflush(stdout)), to detect in which node the crash occurs. After I identified the node that causes the problem implied by the scoring of the branch, I start to add extra conditional prints in the code to see what the problem is.

The thing I hate most is when adding a print statement changes the behavior. This tends to happen when you are inadvertently using an uninitialized local variable, for which the compiler allocated stack memory hat was also used during printf. I even developed a way to do 'transparent printing', which avoids modifying the stack by saving and restoring it, though the following routines:

Code: Select all

int i, saved[10000];
void S() { int stack[10000]; for(i=0; i<10000; i++) saved[i] = stack[i]; }
void R() { int stack[10000]; for(i=0; i<10000; i++) stack[i] = saved[i]; }
(In a separate source file, compiled without optimizations.) And then sandwich any behavior-altering prints between those: if(PATH) S(), printf(...), fflush(stdout), R();. That usually helps to restore the reproducibility of the behavior.

If there is a difference between two versions that should behave the same, I run them both with the printing enabled, (starting in the root), and then follow the move that produced the first deviating score in both versions, until it becomes clear where he difference was generated.

So far this always enabled me to find any bug in a reasonable amount of time, even if it manifested itself only at 24 ply.