Progress On Bricabrac

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Progress On Bricabrac

Post by lithander »

Mike Sherwin wrote: Sun May 09, 2021 6:06 am It appears but might not be true that MCE Chile may been heavily influenced by PeSTO. Maybe Thomas will clarify that.
I used the same dataset of quiet positions (from Zurichess) that was used for training Pesto. But the resulting PSTs look quite different and the engines seem to play different. However as I was previously using PeSTO and my goal was to find tables that could beat the previous version the results are probably especially good against PeSTO. Selection bias, so to speak.

I tried compiling and playing Bric. But I can't reproduce your very good results of the Zygote version beating MinimalChess 0.4.1 (which is the last publicly released version). Both the PeSTO and the PeSTOZygote version do rather poorly in my tests, lose on time, play illegal moves and in short: experience problems.

Code: Select all

Score of MinimalChess 0.4.1 vs BricPESTO: 507 - 13 - 16  [0.961] 536
Score of MinimalChess 0.4.1 vs BricPESTOzygote: 172 - 11 - 8  [0.921] 191
I downloaded the zip from mediafire, compiled the CPP in Visual Studio as you said, one with the zygote define and one without. x64 and Release.

The tournament settings are as follows:

Code: Select all

./cutechess-cli.exe -engine conf="MinimalChess 0.4.1" -engine conf="BricPESTO" -each tc=5+0.5 book=varied.bin -pgnout mmc041_vs_bricPesto.pgn -rounds 1000 -games 2 -repeat -concurrency 5
Here are the PGNs and my compiled binaries: https://www.dropbox.com/s/8fxrjdac9b7bh ... C.zip?dl=0

Let me know what I did wrong!

Edit: I'm now using the Exe from the media-fire link. It does play properly except that it sometimes loses on time. So that must mean my compile didn't work. Can you provide a compiled version of the "zygote" version, too? The zip included only the normal Pesto version, I think.

Edit2: Okay, it's even stranger than that. The illegal moves started to happen again after playing ~50 games. But it wasn't limited to my own compile. Also the Exe you provided shows the same behavior. I'm pretty sure Cute Chess isn't restarting the engines and just uses one instance per thread for all 2000 games. It seems that Bric has some kind of issue that only surfaces after using it to play more than 50 games. Weird.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Mike Sherwin
Posts: 882
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 »

lithander wrote: Mon May 10, 2021 12:18 am
Mike Sherwin wrote: Sun May 09, 2021 6:06 am It appears but might not be true that MCE Chile may been heavily influenced by PeSTO. Maybe Thomas will clarify that.
I used the same dataset of quiet positions (from Zurichess) that was used for training Pesto. But the resulting PSTs look quite different and the engines seem to play different. However as I was previously using PeSTO and my goal was to find tables that could beat the previous version the results are probably especially good against PeSTO. Selection bias, so to speak.

I tried compiling and playing Bric. But I can't reproduce your very good results of the Zygote version beating MinimalChess 0.4.1 (which is the last publicly released version). Both the PeSTO and the PeSTOZygote version do rather poorly in my tests, lose on time, play illegal moves and in short: experience problems.

Code: Select all

Score of MinimalChess 0.4.1 vs BricPESTO: 507 - 13 - 16  [0.961] 536
Score of MinimalChess 0.4.1 vs BricPESTOzygote: 172 - 11 - 8  [0.921] 191
I downloaded the zip from mediafire, compiled the CPP in Visual Studio as you said, one with the zygote define and one without. x64 and Release.

The tournament settings are as follows:

Code: Select all

./cutechess-cli.exe -engine conf="MinimalChess 0.4.1" -engine conf="BricPESTO" -each tc=5+0.5 book=varied.bin -pgnout mmc041_vs_bricPesto.pgn -rounds 1000 -games 2 -repeat -concurrency 5
Here are the PGNs and my compiled binaries: https://www.dropbox.com/s/8fxrjdac9b7bh ... C.zip?dl=0

Let me know what I did wrong!

Edit: I'm now using the Exe from the media-fire link. It does play properly except that it sometimes loses on time. So that must mean my compile didn't work. Can you provide a compiled version of the "zygote" version, too? The zip included only the normal Pesto version, I think.
Ah, sorry I forgot to mention :oops: that in MSVS 2019 I had to turn off Whole Program Optimization to get a stable exe. Try that and in the meantime I'll prepare a new upload. I only use Arena 3.51 and in over 4000 games now at 5 sec and 0.5 sec inc it has not lost on time. I'll have to download cutechess.
User avatar
Guenther
Posts: 4685
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Progress On Bricabrac

Post by Guenther »

Mike Sherwin wrote: Mon May 10, 2021 1:17 am
...
I only use Arena 3.51 and in over 4000 games now at 5 sec and 0.5 sec inc it has not lost on time. I'll have to download cutechess.
That's a grave error when developing a new chess program for several reasons.
https://rwbc-chess.de

Talkchess nowadays is a joke - it is full of trolls/idiots/wafflers/clone lovers/people stuck in the pleistocene > 70% of the posts fall into this category...
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Progress On Bricabrac

Post by lithander »

Mike Sherwin wrote: Mon May 10, 2021 1:17 am Ah, sorry I forgot to mention :oops: that in MSVS 2019 I had to turn off Whole Program Optimization to get a stable exe. Try that and in the meantime I'll prepare a new upload.
As I added it my 2nd edit of the above post the weird behaviour also happened with the compiled executable that you supplied. I guess the best course of action would be for you to try and reproduce my test settings (I hope I included all relevant information?) and experience the errors for yourself, hopefully providing you with a chance to find a fix.

But when you have new builds I'll test them of course.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Mike Sherwin
Posts: 882
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 »

lithander wrote: Mon May 10, 2021 10:46 am
Mike Sherwin wrote: Mon May 10, 2021 1:17 am Ah, sorry I forgot to mention :oops: that in MSVS 2019 I had to turn off Whole Program Optimization to get a stable exe. Try that and in the meantime I'll prepare a new upload.
As I added it my 2nd edit of the above post the weird behaviour also happened with the compiled executable that you supplied. I guess the best course of action would be for you to try and reproduce my test settings (I hope I included all relevant information?) and experience the errors for yourself, hopefully providing you with a chance to find a fix.

But when you have new builds I'll test them of course.
Last Friday I got the first Moderna vaccine injection. By Saturday and especially Sunday I was fighting off extreme tiredness with lots of caffeine. No flu like symptoms though. I've been sleeping most of the last 15 hours. This morning the last couple of days are mostly gone and I do not remember much. It will take me some time to get back on track.
Mike Sherwin
Posts: 882
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 downloaded the source to make sure that I was working from the same source. Now it does not go lower than 2 seconds. Also I made sure Whole Program Optimization was turned off. Started the gauntlets. Let's see what happens.
Mike Sherwin
Posts: 882
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 am now of the opinion that Zygote's learning at extremely fast time controls like 5s + 500ms is nothing but noise. So a 30sec per move gauntlet is now underway to test that notion.

BricPESTO1 - MinimalChessEngine : 36.0/100 23-51-26 (101000=10=0=00011110000000=110001110=000100000=1000=0000==1=0111101====0=0=====001000=0001==001===00) 36% -100
BricPESTO1 - Rustic-alpha-2_64-bit-popcnt : 45.0/100 36-46-18 (100010==0111000000==001101111110=1110=0=110011=100=000=001=0011011=0001010=000==010=1010100001011==1) 45% -35
BricPESTO1 - Tscp181 : 59.0/100 49-31-20 (101=011=10011000=011=0001=01=110=111=1111100011101011==110=1==111001100100==0==111100011=01=110111=1) 59% +63

1939 - 100 = 1839
1815 - 35 = 1780
1724 + 63 = 1885
performance = 1834

BricPESTOz1 - MinimalChessEngine : 26.5/100 19-66-15 (001001=00=10=00000100000000110010=0000010000=0101=0001=0000===10=01000000=000001=01000110000=1000=01) 27% -173
BricPESTOz1 - Rustic-alpha-2_64-bit-popcnt : 48.5/100 41-44-15 (101001=001=110=000=11110111=001000011=0100001011111010=010100010100100001==0=0110==111=010=11010101=) 49% -7
BricPESTOz1 - Tscp181 : 64.0/100 57-29-14 (1111010=11101==1=100100000110011=011=1110==111110111011101111=000100=11011=0=1100111=11110110111110=) 64% +100

1939 - 173 = 1766
1815 - 7 = 1808
1724 + 100 = 1824
performance = 1799

https://www.mediafire.com/file/kn5wug3d ... 1.zip/file

Whether I did everything right this time or not I have to be done with PeSTO. Thanks!
Mike Sherwin
Posts: 882
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 have been undecided upon how to fashion the evaluation. I did not want to merely repeat what was done in RomiChess. I wanted to underpin it with a concept that did not rely on arbitrary rules of thumb like bonusing a knight just because it is in the center. I wanted something that the rest of the eval could be crafted around to support and strengthen the foundational concept. For example I don't want to write pawn push code just for the sake of pushing pawns. I really do not have the words to convey my thinking but I think that the following code and sample game might make it more clear.

I remembered something that David Bronstein once wrote in one of his books. Paraphrased, 'The key to making strong moves is to not put pieces on squares in which they can be advantageously attacked in one turn'. In the following code only second move mobility is counted for non attacked squares. If the first move's to-square is attacked the second move mobility from that square is not counted. Once there is a SEE function I will modify that to use the SEE function. The code is just the basic idea and nothing more. It is the foundation that I want to build upon.

Code: Select all

void InitSearch(Thread* t) {
  u64 bb, cc, b, a, pieces, allPieces;
  u32 sq;
  s32 i, col, cenCol, row, cenRow;
  SplitBB blocks;

  allPieces = piece[WHITE] | piece[BLACK];

  for (i = A1; i <= H8; i++) {
    col = i & 7;
    row = i >> 3;
    cenCol = col < 4 ? col : 7 - col;
    cenRow = row < 4 ? row : 7 - row;

    // white pawns
    wpPST[i] = 0;
    
    // black pawns
    bpPST[i] = 0;

    // white knights
    wnPST[i] = 0;
    bb = knightMoves[i] & ~piece[WHITE];
    while (bb) {
      _BitScanForward64(&sq, bb);
      bb ^= one << sq;
      if (!AtkByBlack(t, one << sq)) {
        cc = knightMoves[sq] & ~piece[WHITE];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          wnPST[i] += (1 - AtkByBlack(t, one << sq));
        }
      }
    }

    // black knights
    bnPST[i] = 0;
    bb = knightMoves[i] & ~piece[BLACK];
    while (bb) {
      _BitScanForward64(&sq, bb);
      bb ^= one << sq;
      if (!AtkByWhite(t, one << sq)) {
        cc = knightMoves[sq] & ~piece[BLACK];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          bnPST[i] += (1 - AtkByWhite(t, one << sq));
        }
      }
    }

    // bishops
    blocks.bb = allPieces & b7e[i];
    blocks.bb = ((blocks.l32 >> 8) | blocks.h32);
    bb = bss[i][blocks.r1][0]
       & bss[i][blocks.r2][1]
       & bss[i][blocks.r3][2];

    // white bishops
    wbPST[i] = 0;
    b = bb & ~piece[WHITE];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByBlack(t, one << sq)) {
        blocks.bb = allPieces & b7e[sq];
        blocks.bb = ((blocks.l32 >> 8) | blocks.h32);
        cc = bss[sq][blocks.r1][0]
           & bss[sq][blocks.r2][1]
           & bss[sq][blocks.r3][2]
           & ~piece[WHITE];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          wbPST[i] += (1 - AtkByBlack(t, one << sq));
        }
      }
    }

    // black bishops
    bbPST[i] = 0;
    b = bb & ~piece[BLACK];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByWhite(t, one << sq)) {
        blocks.bb = allPieces & b7e[sq];
        blocks.bb = ((blocks.l32 >> 8) | blocks.h32);
        cc = bss[sq][blocks.r1][0]
           & bss[sq][blocks.r2][1]
           & bss[sq][blocks.r3][2]
           & ~piece[BLACK];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          bbPST[i] += (1 - AtkByWhite(t, one << sq));
        }
      }
    }

    // rooks
    blocks.bb = allPieces & rob[i];
    bb = qss[i][(blocks.bb >> (i & 56)) & 127][0]
       & qss[i][blocks.r2][1]
       & qss[i][blocks.r3][2]
       & qss[i][blocks.r4][3]
       & qss[i][blocks.r5][4]
       & qss[i][blocks.r6][5]
       & qss[i][blocks.r7][6]
       & rob[i];

    // white rooks
    wrPST[i] = 0;
    b = bb & ~piece[WHITE];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByBlack(t, one << sq)) {
        blocks.bb = allPieces & rob[sq];
        cc = qss[sq][(blocks.bb >> (i & 56)) & 127][0]
          & qss[sq][blocks.r2][1]
          & qss[sq][blocks.r3][2]
          & qss[sq][blocks.r4][3]
          & qss[sq][blocks.r5][4]
          & qss[sq][blocks.r6][5]
          & qss[sq][blocks.r7][6]
          & rob[sq]
          & ~piece[WHITE];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          wrPST[i] += (1 - AtkByBlack(t, one << sq));
        }
      }
    }

    // black rooks
    brPST[i] = 0;
    b = bb & ~piece[BLACK];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByWhite(t, one << sq)) {
        blocks.bb = allPieces & rob[sq];
        cc = qss[sq][(blocks.bb >> (i & 56)) & 127][0]
          & qss[sq][blocks.r2][1]
          & qss[sq][blocks.r3][2]
          & qss[sq][blocks.r4][3]
          & qss[sq][blocks.r5][4]
          & qss[sq][blocks.r6][5]
          & qss[sq][blocks.r7][6]
          & rob[sq]
          & ~piece[BLACK];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          brPST[i] += (1 - AtkByWhite(t, one << sq));
        }
      }
    }

    // queens
    blocks.bb = allPieces & rob[i];
    bb = qss[i][(blocks.bb >> (i & 56)) & 127][0]
      & qss[i][blocks.r2][1]
      & qss[i][blocks.r3][2]
      & qss[i][blocks.r4][3]
      & qss[i][blocks.r5][4]
      & qss[i][blocks.r6][5]
      & qss[i][blocks.r7][6];

    // white queens
    wqPST[i] = 0;
    b = bb & ~piece[WHITE];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByBlack(t, one << sq)) {
        blocks.bb = allPieces & (rob[sq] | bob[sq]);
        cc = qss[sq][(blocks.bb >> (i & 56)) & 127][0]
          & qss[sq][blocks.r2][1]
          & qss[sq][blocks.r3][2]
          & qss[sq][blocks.r4][3]
          & qss[sq][blocks.r5][4]
          & qss[sq][blocks.r6][5]
          & qss[sq][blocks.r7][6]
          & ~piece[WHITE];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          wqPST[i] += (1 - AtkByBlack(t, one << sq));
        }
      }
    }

    // black queens
    bqPST[i] = 0;
    b = bb & ~piece[BLACK];
    while (b) {
      _BitScanForward64(&sq, b);
      b ^= one << sq;
      if (!AtkByWhite(t, one << sq)) {
        blocks.bb = allPieces & (rob[sq] | bob[sq]);
        cc = qss[sq][(blocks.bb >> (i & 56)) & 127][0]
          & qss[sq][blocks.r2][1]
          & qss[sq][blocks.r3][2]
          & qss[sq][blocks.r4][3]
          & qss[sq][blocks.r5][4]
          & qss[sq][blocks.r6][5]
          & qss[sq][blocks.r7][6]
          & ~piece[BLACK];
        while (cc) {
          _BitScanForward64(&sq, cc);
          cc ^= one << sq;
          bqPST[i] += (1 - AtkByWhite(t, one << sq));
        }
      }
    }

    // white king
    wkPST[i] = ((2000 - mat[BLACK]) / 200) * cenCol * cenRow;

    // black king
    bkPST[i] = ((2000 - mat[WHITE]) / 200) * cenCol * cenRow;
  }

  pos[WHITE] = 0;
  pos[BLACK] = 0;
  mat[WHITE] = 0;
  mat[BLACK] = 0;

  pieces = piece[WHITE];
  while (pieces) {
    _BitScanForward64(&sq, pieces);
    pieces ^= one << sq;
    mat[WHITE] += value[board[sq]];
    pos[WHITE] += pcePST[board[sq]][sq];
  }

  pieces = piece[BLACK];
  while (pieces) {
    _BitScanForward64(&sq, pieces);
    pieces ^= one << sq;
    mat[BLACK] += value[board[sq]];
    pos[BLACK] += pcePST[board[sq]][sq];
  }
}

[pgn][Event "Computer chess game"]
[Site "DESKTOP-HFVHK2B"]
[Date "2021.05.13"]
[Round "?"]
[White "Bricabrac"]
[Black "Bricabrac"]
[Result "1/2-1/2"]
[BlackElo "2000"]
[ECO "A00"]
[Opening "Van Kruij's Opening"]
[Time "13:02:35"]
[WhiteElo "2000"]
[TimeControl "0+30"]
[Termination "normal"]
[PlyCount "153"]
[WhiteType "program"]
[BlackType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g2f3 d5d4 f3f4 d4d5 f2e4)
-2.97/12 29} Nf2 {(h1f2 d5d4 g3g2 f4g2 f1g2 d4c4 g2f3 c4d5 f3f4 d5d4 f2g4
d4d5 g4e3) +2.95/13 29} 76. Kd4 {(d5d4 g3g2 f4g2 f1g2 d4c4 g2f3 c4d5 f3f4
d5d4 f2g4 d4d5 g4e5) -2.94/12 30} g2 {(g3g2 f4g2 f1g2 d4c4 g2f3 c4d5 f3e3
d5e5 e3d3 e5d5 f2g4 d5d6 d3d4) +3.35/13 29} 77. Nxg2 {(f4g2 f1g2 d4c4 g2f3
c4d5 f3e3 d5e5 e3d3 e5d5 f2g4 d5d6) -3.11/11 30 Insufficient material}
1/2-1/2
[/pgn]
Mike Sherwin
Posts: 882
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 wanted to jump right in and start adding to the eval but resisted long enough to get a baseline result for the above code. Besides I had to leave the house for a few hours.

Bricabrac1 - Tscp181 : 9.0/100 6-88-6 (0100000000000000001000000000000000010000000000000=000000000=000000=000000000=000=000010100000=100000) 9% -402

Even though at first glance it is a horrific looking result it really is not that bad. And about what I had expected for 1 sec per move. At 30 seconds per move it can see the value in pushing pawns. At 1 second per move it will push a pawn to help a piece develop but refuses to try and promote or to stop an opponents pawn from advancing until it is too late. I have started a 30 second per move match. I'll report on that in about 3 days.

Next on the list.
1. While counting safe squares for move two of a piece is pretty good it does matter the location of those squares.
2. Bonusing winning attacks.
3. Bonusing if has a safe retreat square.
4. Normalizing the values to some maximum for each piece type.
5. Pawn structure.
6. Pawn evaluation hash.
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Progress On Bricabrac

Post by lithander »

Your work and comments have inspired me to try and add a dynamic component to MinimalChess' evaluation wich is atm using PSTs only.

I don't want to replace the PSTs but augment them. The dynamic component will make use of a tunable table also. That way I don't have to hardcode chess knowledge into the engine but enable the tuner to derive it statistically from a dataset of games just like with the PSTs.

What I'm currently testing is an implementation where for each piece on the board it will look at all the squares it could potentially move to. If the square is empty it doesn't affect the score but for each friendly and opponent piece encountered a bonus or malus is added to the score. These bonuses come from a tunable table of size 6x6x2.

The results are promising and seem to make a lot of sense intuitively. For example there's a bonus of 9 if a pawn can attack a friendly other pawn's square. This leads to a better looking pawn structure than what PSTs can do on their own.

Code: Select all

          // Friends                                      Foes
          // P      N      B      R      Q      K         P      N      B      R      Q      K
             9,     7,    13,     3,    -2,    -6,        0,    27,    36,    15,    32,    84, //P
            -1,     0,    -2,     0,     3,    -1,       -5,     0,    18,    15,    14,    30, //N
           -11,    -3,    34,     3,    -6,    -5,       -4,    11,     0,     8,    19,    20, //B
           -10,    -2,     2,    -2,    -1,    -3,       -4,    -2,     1,     0,    10,     5, //R
            -3,     1,     4,    -4,   -34,    -3,       -2,    -3,     0,     3,     0,     6, //Q
             6,     0,     7,    -8,    -3,     0,       30,     5,     9,     3,   -34,     0, //K
This is what the tuner found to be good values for my current implementation. For example it seems to make sense for a pawn to guard other pawns (9), knights (7) and bishops (13) but not queens and certainly not kings. And if your pawn can attack an enemy piece that always warrants a huge bonus for each type except other pawns. (Because they can then also attack you so there's no bonus for one side)

There are different implementation details I want to try... For example, when do you stop giving a bonus for sliders? after the first piece on the axis? after the 2nd? Or not at all? (what I do currently) Or... should there be a distinct table for midgame and endgame? But this is the general direction I'm going to try to improve MinimalChess' evaluation with. And preliminary results are promising.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess