MadChess 3.1 Beta 2b475bc (Color-Agnostic Code)

I removed 350 lines of code from MadChess and increased its playing strength by 12 Elo. I’m happy with the ratio.

The bulk of changes since my last blog post involve replacing redundant, color-specific code with color-agnostic code, mostly in the Eval class. I replaced code such as this…

… with code that’s generalized for multiple pieces and colors.

The above is just one example of refactored code. There are many others in PR 22 that adds 2,641 lines of code and removes 3,336 lines of code (net -695 lines of code). This refactoring took a lot of time. I was careful to test often to ensure my (partial) changes did not weaken the engine due a mistake when translating color-specific code to color-agnostic code via array lookups indexed by colorless piece.

The Board.GetSquareFromWhitePerspective method violates the spirit of my refactoring. However, an exception is warranted because I don’t bother storing white and black piece location values in separate tables. For black, I simply lookup the corresponding square from white’s side of the board.

In addition to color-agnostic refactoring, I made other code quality improvements in a series of Pull Requests.

Combined, the five PRs removed 350 lines of code. This increased the playing strength of MadChess 3.1 Beta by 12 Elo.

 

Feature Category Date Commit1 WAC2 Elo Rating3 Improvement
Color-Agnostic Code Evaluation 2021 Sep 13 2b475bc 286 2629 +12
Singular Move Search 2021 Jun 14 0c601ea 290 2617 +13
Endgame Eval Scaling Evaluation 2021 Apr 08 4d22dec 286 2604 +12
Bishop Pair Evaluation 2021 Mar 14 2960ec9 285 2592 +22
Position Cache Optimization Search 2021 Feb 23 42d7702 286 2570 +8
Move Generation Optimization Search 2021 Feb 17 22002dc 287 2562 +12
PVS and Null Move Search 2021 Feb 09 f231dac 285 2550 +20
Remove Aspiration Windows Search 2020 Dec 20 4b7963b 290 2530 +9
Time Management Search 2020 Dec 19 d143bb5 286 2521 +8
Crash Bug Search 2020 Aug 29 2d855ec 288 2513 +0
King Safety Evaluation 2020 Aug 16 6794c89 288 2513 +63
Eval Param Tuning Evaluation 2020 Jul 23 bef88d5 283 2450 +30
Late Move Pruning Search 2020 Feb 08 6f3d17a 288 2420 +29
Piece Mobility Evaluation 2020 Feb 01 5c5d4fc 282 2391 +62
Passed Pawns Evaluation 2018 Dec 27 103 279 2329 +119
Staged Move Generation Search 2018 Dec 15 93 275 2210 +39
History Heuristics Search 2018 Dec 03 84 275 2171 +28
Eval Param Tuning Evaluation 2018 Nov 24 75 272 2143 +47
Sophisticated Search
Material and Piece Location
Baseline 2018 Nov 08 58 269 2096 0
  1. GitHub commit (hash) or Subversion source code revision (integer)
  2. Win At Chess position test, 3 seconds per position
  3. Bullet chess, 2 min / game + 1 sec / move

The Mad Lot

MadChess 3.0 participated in a tournament Graham Banks arranged, named The Mad Lot.

“The Mad Lot”, ha ha. My engine’s namesake tournament. Rising to the occasion, MadChess 3.0 won the tournament! That’s two consecutive tournament victories for MadChess.

                                1    2    3    4    5    6    7    8    9    0    1    2    3    4    
1   MadChess 3.0 64-bit         **** ½½0½ 0111 1½01 0011 ½½½1 11½0 ½10½ ½½½½ 1½11 1½11 ½111 1½1½ 1½11  35.0/52
2   Nalwald 1.10 64-bit         ½½1½ **** 101½ 1½10 01½1 1010 1100 10½1 ½1½0 11½1 1½11 ½011 ½11½ 11½1  34.5/52
3   Coiled 0.6 64-bit           1000 010½ **** 1111 ½101 0½11 ½½1½ 0½11 1½01 111½ ½1½1 ½11½ ½101 1001  33.0/52
4   CM9000 Default              0½10 0½01 0000 **** ½011 00½1 ½11½ 111½ 1½00 ½½1½ 1110 1½01 ½½11 1110  29.0/52
5   Ceibo 0.7 64-bit            1100 10½0 ½010 ½100 **** 1½½½ 0½1½ 101½ 0111 ½½10 1101 101½ 0100 0111  28.0/52  706.75
6   RookieMonster 1.9.2 64-bit  ½½½0 0101 1½00 11½0 0½½½ **** ½00½ ½1½0 ½10½ 0½01 1½01 1111 11½1 ½110  28.0/52  681.25
7   Zahak 4.0 64-bit            00½1 0011 ½½0½ ½00½ 1½0½ ½11½ **** 00½½ 0½11 10½0 ½½01 ½½11 101½ 1111  27.5/52
8   Ghost 3.1 64-bit            ½01½ 01½0 1½00 000½ 010½ ½0½1 11½½ **** ½½11 ½00½ 10½0 1111 11½1 ½1½0  27.0/52
9   Raven 1.10 64-bit           ½½½½ ½0½1 0½10 0½11 1000 ½01½ 1½00 ½½00 **** 1110 ½½0½ 01½1 0111 ½10½  25.5/52
10  Dorky 4.8 64-bit            0½00 00½0 000½ ½½0½ ½½01 1½10 01½1 ½11½ 0001 **** 10½0 1½10 ½0½1 1½01  22.5/52
11  Galjoen 0.41.2 64-bit       0½00 0½00 ½0½0 0001 0010 0½10 ½½10 01½1 ½½1½ 01½1 **** 1010 1½01 0011  21.5/52
12  Trace 1.37a                 ½000 ½100 ½00½ 0½10 010½ 0000 ½½00 0000 10½0 0½01 0101 **** 11½1 ½1½½  18.0/52
13  CT800 1.42 64-bit           0½0½ ½00½ ½010 ½½00 1011 00½0 010½ 00½0 1000 ½1½0 0½10 00½0 **** ½101  17.5/52
14  Qapla 0.1.1 64-bit          0½00 00½0 0110 0001 1000 ½001 0000 ½0½1 ½01½ 0½10 1100 ½0½½ ½010 ****  17.0/52

Games

Banks 86th Amateur Series Division 7

MadChess 3.0 participated in Graham Banks’ 86th amateur tournament in division 7.

MadChess 3.0 won the tournament! I believe this is MadChess’ first tournament win.

                                1    2    3    4    5    6    7    8    9    0    1    2    
1   MadChess 3.0 64-bit         **** ½1½1 ½½11 1010 ½111 1½01 0101 ½10½ 1000 ½001 ½1½½ 1111  27.0/44  586.25
2   Drosophila 1.6 64-bit       ½0½0 **** 00½1 1½½1 ½½½0 01½½ 11½½ ½½1½ 1110 ½1½½ 0111 1111  27.0/44  558.50
3   KnightX 2.8 64-bit          ½½00 11½0 **** 1010 1011 ½½1½ 01½½ 11½0 01½½ 101½ 1011 01½½  25.0/44  536.00
4   Supernova 2.3 64-bit        0101 0½½0 0101 **** ½0½0 ½111 ½011 1½½½ 1½1½ ½½1½ ½½11 ½10½  25.0/44  528.00
5   paulchen332 0.1.1 64-bit    ½000 ½½½1 0100 ½1½1 **** ½110 ½10½ ½1½½ ½11½ 11½0 1100 1100  23.5/44
6   RookieMonster 1.9.2 64-bit  0½10 10½½ ½½0½ ½000 ½001 **** ½1½1 11½½ 1100 ½1½½ 1011 0½½1  22.5/44
7   Nalwald 1.9 64-bit          1010 00½½ 10½½ ½100 ½01½ ½0½0 **** ½111 1100 ½½11 1½01 0½10  22.0/44  472.75
8   Lozza 2.0 64-bit            ½01½ ½½0½ 00½1 0½½½ ½0½½ 00½½ ½000 **** ½½1½ 1111 1½½1 11½½  22.0/44  456.25
9   Delocto 200419 64-bit       0111 0001 10½½ 0½0½ ½00½ 0011 0011 ½½0½ **** 0½10 ½001 1½10  19.0/44
10  Jumbo 0.7.0 64-bit          ½110 ½0½½ 010½ ½½0½ 00½1 ½0½½ ½½00 0000 1½01 **** 0½01 ½½1½  17.5/44
11  Raven 1.10 64-bit           ½0½½ 1000 0100 ½½00 0011 0100 0½10 0½½0 ½110 1½10 **** 1010  17.0/44
12  Axolotl 1.9 64-bit          0000 0000 10½½ ½01½ 0011 1½½0 1½01 00½½ 0½01 ½½0½ 0101 ****  16.5/44

Games

MadChess 3.1 Beta 0c601ea (Singular Move)

I strengthened MadChess by extending the search horizon of singular moves. I gleaned the idea from the Stockfish chess engine.

Quoting from my Pull Request #17:

  • In the GetSearchHorizon method, added call to a new method, IsBestMoveSingular, that determines if best move that had failed high in recent searches is best by a significant margin.
  • If so, extend the search by one ply. A code comment explains why:
    • The best move (from the cache) is singular. That is, it’s the only good move in the position.
    • Evaluation of the current position relies on the accuracy of the singular move’s score.
    • If the engine misjudges the singular move, the position could deteriorate because no alternative strong moves exist.
    • To increase confidence in the singular move’s score, search it one ply deeper.

In addition, in Pull Request #16 I implemented asymptotic history scores. This simplifies keeping history scores within defined bounds. Also I fixed a bug in the Standard Algebraic Notation (SAN) parser for positions where the moving piece is disambiguated by square (not merely by rank or file). These changes improved code quality but did not increase playing strength.

Singular move increased the playing strength of MadChess 3.1 Beta by 13 Elo.

 

Feature Category Date Commit1 WAC2 Elo Rating3 Improvement
Singular Move Search 2021 Jun 14 0c601ea 290 2617 +13
Endgame Eval Scaling Evaluation 2021 Apr 08 4d22dec 286 2604 +12
Bishop Pair Evaluation 2021 Mar 14 2960ec9 285 2592 +22
Position Cache Optimization Search 2021 Feb 23 42d7702 286 2570 +8
Move Generation Optimization Search 2021 Feb 17 22002dc 287 2562 +12
PVS and Null Move Search 2021 Feb 09 f231dac 285 2550 +20
Remove Aspiration Windows Search 2020 Dec 20 4b7963b 290 2530 +9
Time Management Search 2020 Dec 19 d143bb5 286 2521 +8
Crash Bug Search 2020 Aug 29 2d855ec 288 2513 +0
King Safety Evaluation 2020 Aug 16 6794c89 288 2513 +63
Eval Param Tuning Evaluation 2020 Jul 23 bef88d5 283 2450 +30
Late Move Pruning Search 2020 Feb 08 6f3d17a 288 2420 +29
Piece Mobility Evaluation 2020 Feb 01 5c5d4fc 282 2391 +62
Passed Pawns Evaluation 2018 Dec 27 103 279 2329 +119
Staged Move Generation Search 2018 Dec 15 93 275 2210 +39
History Heuristics Search 2018 Dec 03 84 275 2171 +28
Eval Param Tuning Evaluation 2018 Nov 24 75 272 2143 +47
Sophisticated Search
Material and Piece Location
Baseline 2018 Nov 08 58 269 2096 0
  1. GitHub commit (hash) or Subversion source code revision (integer)
  2. Win At Chess position test, 3 seconds per position
  3. Bullet chess, 2 min / game + 1 sec / move

Banks 85th Amateur Series Division 7

MadChess 3.0 participated in Graham Banks’ 85th amateur tournament in division 7.

                                1    2    3    4    5    6    7    8    9    0    1    2    
1   Nawito 2103                 **** 0½11 11½0 11½1 ½01½ 1½11 ½½00 ½001 1½11 0111 1111 ½½11  30.0/44
2   Betsabe II 2020             1½00 **** 101½ 1110 0110 0½1½ ½½10 111½ 1101 1½1½ 101½ 1111  29.0/44
3   FrankWalter 2.4.0 64-bit    00½1 010½ **** ½½10 110½ 01½0 1011 1½11 0101 ½110 ½½1½ 01½½  24.5/44
4   MadChess 3.0 64-bit         00½0 0001 ½½01 **** 11½0 ½010 1001 ½11½ 1100 1010 ½½1½ 1111  23.0/44
5   Jumbo 0.7.0 64-bit          ½10½ 1001 001½ 00½1 **** 00½½ ½½1½ 001½ 1110 0111 ½01  0½1½  21.5/43  468.25
6   paulchen332 0.1.1 64-bit    0½00 1½0½ 10½1 ½101 11½½ **** 0010 ½01½ 111½ 0010 ½110 ½½00  21.5/44  466.75
7   Axolotl 1.9 64-bit          ½½11 ½½01 0100 0110 ½½0½ 1101 **** ½0½0 00½1 ½0½½ 011½ 1001  21.0/44
8   Delocto 200419 64-bit       ½110 000½ 0½00 ½00½ 110½ ½10½ ½1½1 **** 00½½ ½01½ 1½½0 11½½  20.0/44  425.00
9   RookieMonster 1.8.2 64-bit  0½00 0010 1010 0011 0001 000½ 11½0 11½½ **** 1111 0½½½ 1001  20.0/44  417.75
10  Galjoen 0.41.1 64-bit       1000 0½0½ ½001 0101 1000 1101 ½1½½ ½10½ 0000 **** 0101 1½½1  19.0/44
11  Detroid 1.0.1 64-bit        0000 010½ ½½0½ ½½0½ ½10  ½001 100½ 0½½1 1½½½ 1010 **** 110½  18.0/43
12  Waxman 2020                 ½½00 0000 10½½ 0000 1½0½ ½½11 0110 00½½ 0110 0½½0 001½ ****  15.5/44

Games