MadChess Blunders… Er, Wait

Gene Wilder as Dr. Frankenstein

I had a Frankenstein moment yesterday. I use the word “Frankenstein” in reference to MadChess. Meaning, I’ve used my powers of concentration to create this thing, a chess engine, by imagining, thinking, then writing code to “teach” it to play a game of chess. This thing becomes terribly powerful. It’s capable of playing the game I “taught” it with the strength of a super Grandmaster, far exceeding my abilities.

While I’m glad I can use MadChess to analyze my games against Internet opponents (after the game is complete, of course), and rely on MadChess’ suggested improvements and variations (it is a Grandmaster after all), it would be nice to play a game against it. For that to be enjoyable, though, I must handicap MadChess so it plays weaker and gives me a fighting chance to win.

The Universal Chess Interface (UCI), a protocol supported by chess applications that enables users to connect the application to any chess engine, supports handicapping an engine via the UCI_LimitStrength and UCI_Elo options. The user selects a playing strength (Elo rating). It’s up to the engine’s author to determine how to simulate weak play at the specified Elo rating.

In MadChess’ source code, I accomplish this via four techniques:

  1. Removing knowledge (of piece mobility, king safety, pawn structure, etc).
  2. Decreasing search speed (examine, say, 1,500 positions per second instead of two million).
  3. Randomly selecting an inferior move at most e centipawns worse than the best move (where e varies inversely with Elo rating).
  4. Occasionally (p percent of moves), selecting a blunder (seriously inferior move) at most b centipawns worse (where b is much greater than e).

See The MadChess UCI_LimitStrength Algorithm for details.

So I’m playing a 5m + 5s blitz game against MadChess. I’ve handicapped MadChess by limiting its strength to 900 Elo. As the author of the engine I know this implies MadChess will blunder on approximately 11% of its moves. This blunder can be as severe as approximately 400 centipawns, which is greater than the value of a knight or bishop. I know this because I wrote the code and devised the handicapping formulas.

I play white, MadChess plays black. The game begins 1.e4 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 h5 5.Nc3 Nf6 6.Bc4 Na5 7.Be2 e5 8.Nf3 Bb4 9.Bd2 Rh6 10.Nxe5 Rh8 11.Nc4 Rb8 12.O-O Nxc4 13.Bxc4 Qc7 14.Qe2 Ng4 15.g3 Qd8 16.a3 Bd6 17.Nd5 Bc5 18.Qf3.

1rbqk2r/pp1p1pp1/8/2bN3p/2B1P1n1/P4QP1/1PPB1P1P/R4RK1 b - - 4 18

I’m up a pawn. Now MadChess threatens my queen and light-squared bishop via 18… Ne5. I evade the threat to my queen and protect my bishop by playing 19. Qc3, eyeing black’s undefended knight on e5 and pawn on g7. MadChess persists, threatening my queen again via 19… Bd4.

1rbqk2r/pp1p1pp1/8/3Nn2p/2BbP3/P1Q3P1/1PPB1P1P/R4RK1 w - - 7 20

Er, wait… that move makes no sense. Doesn’t it simply blunder the bishop? I examine the board and determine black’s bishop on d4 is unprotected by any of its pieces. “Oh,” I think to myself, “this must be MadChess’ limit-strength algorithm kicking in. The engine is making an idle threat but hanging its bishop. This is well within the 400 centipawn blunder it may play once every nine moves or so.” I capture the black bishop via 20. Qxd4.

1rbqk2r/pp1p1pp1/8/3Nn2p/2BQP3/P5P1/1PPB1P1P/R4RK1 b - - 0 20

Frankenstein, I mean MadChess, replies 20… Nf3+, forking my king and queen. Doh!

1rbqk2r/pp1p1pp1/8/3N3p/2BQP3/P4nP1/1PPB1P1P/R4RK1 w - - 1 21

I walked into that trap. I played on hoping MadChess would blunder some material back to me, leveling the game. But it was I who made further mistakes. I resigned after black’s 33rd move forked another of my pieces.

So I have used my powers of concentration to create a chess engine (via coding) that can defeat my powers of concentration (playing a game of chess).

So I have used my powers of concentration to create a chess engine (via coding) that can defeat my powers of concentration (playing a game of chess). I attempt to weaken my creation, act satisfied when I believe it has indeed played a weak move, then am smacked in the face by the brutish engine. Surreal.

To correct this problem, I need to code less and play more.

After the game I gave Komodo Dragon, a world-class chess engine, two seconds per move to analyze the game. See the full game, with Komodo’s suggested improvements, below.

Into The Void

MadChess 3.1 participated in a tournament Graham Banks arranged, named Into The Void.

This is MadChess 3.1’s debut tournament. As a fan of Black Sabbath, I must say I approve of the name of the tournament.

                           1    2    3    4    5    6    7    8    9    0    1    2    
1   Nawito 22.07 64-bit    **** 1010 0½½1 1010 111½ 00½1 ½1½½ ½½½½ ½1½1 ½111 ½101 110½  27.0/44
2   CM11th Archangel       0101 **** ½½01 ½½01 1½½½ ½11½ ½½0½ 110½ 10½1 ½½10 ½½11 101½  25.5/44
3   Inanis 1.1.0 64-bit    1½½0 ½½10 **** ½½01 11½½ ½0½½ ½½10 ½½½0 ½110 ½101 10½½ 1011  24.0/44  517.25
4   K2 0.99                0101 ½½10 ½½10 **** 1½00 0100 ½001 111½ ½½½1 ½1½0 1111 0½1½  24.0/44  514.50
5   MadChess 3.1 64-bit    000½ 0½½½ 00½½ 0½11 **** 10½½ 1½½1 ½½½1 0010 ½111 ½11½ ½11½  23.5/44
6   Delocto 200419 64-bit  11½0 ½00½ ½1½½ 1011 01½½ **** 00½1 10½½ 01½½ 010½ ½0½0 ½111  22.5/44
7   Chess Tiger 2007.1     ½0½½ ½½1½ ½½01 ½110 0½½0 11½0 **** 0½½0 ½½½0 ½111 01½0 1½½½  22.0/44
8   Blunder 8.5.5 64-bit   ½½½½ 001½ ½½½1 000½ ½½½0 01½½ 1½½1 **** ½10½ 010½ 0011 110½  21.0/44
9   Lozza 2.4 64-bit       ½0½0 01½0 ½001 ½½½0 1101 10½½ ½½½1 ½01½ **** 0001 ½0½1 ½½1½  20.5/44
10  ECE 20.1 64-bit        ½000 ½½01 ½010 ½0½1 ½000 101½ ½000 101½ 1110 **** ½1½½ 1½½0  19.5/44
11  Leorik 2.2 64-bit      ½010 ½½00 01½½ 0000 ½00½ ½1½1 10½1 1100 ½1½0 ½0½½ **** 1½10  19.0/44
12  KnightX 3.4 64-bit     001½ 010½ 0100 1½0½ ½00½ ½000 0½½½ 001½ ½½0½ 0½½1 0½01 ****  15.5/44

Games

Hans Niemann Is an Andy Kaufman-Like Character

Hans Niemann stares down Magnus Carlsen.

I posted the following message on TalkChess, a forum focused on chess engine programming. The topic is tangentially related to chess engine programming.

Drama in the World of Chess

Nineteen year-old Hans Niemann, unknown in the world of elite chess until very recently, sporting an improbably flat then steep rating progression, defeated World Champion Magnus Carlsen in a tournament game. Did Hans cheat? Did he receive computer assistance? Or did Magnus play poorly?

My Thoughts (Posted on TalkChess)

Hans Niemann strikes me as an Andy Kaufman-like character. You know, someone who gets off on people hating him, loves playing the villain, loves orchestrating a long con, seems anxious for a big reveal where he can expose his detractors as idiots, then bask in his sanctimony.

That’s my impression of him. He seems to be playing a character: the wild-eyed, misunderstood genius who cannot suffer fools and is impatient with the unimaginative, bourgeois chess establishment.

Whether this is based on…

  1. Derogatory comments Hans endured while stuck in the 2400s (not smart enough, not talented enough, etc) that inspired him to seek revenge by doubling-down his efforts, leading to a legitimate rise to the elite level, or…
  2. Hans realizing there’s no audience for the bad-boy, trash-talking villain in the 2400s; that no one cares unless the villain rises to the top and knocks the princes and kings off their thrones; so Hans decided to leverage computer assistance to get himself on the stage.

… is unclear to me at this time.

I’m skeptical based on Niemann’s history of cheating online. Plus GMs have said his post-game analysis is incoherent. Plus GM Larry Kaufman’s story (earlier in this thread) indicating Kaufman likely personally experienced playing against a cheater who couldn’t competently discuss the game he just played. I interpreted it as an experienced chess pro saying yes, it happens.

What a drama.

Follow the Story

What is this all about? Get caught up by reading a timeline of events.

Follow discussion of the drama, including my comments, here: Carlsen Withdrawal After Loss to Niemann.

MadChess 3.1 Released

I have released version 3.1 of my chess engine. I worked on the engine over the last year occasionally, when I had time in the evenings. Slowly, I’ve added about 100 Elo points of playing strength compared to the prior release.

This release includes strength improvements achieved by Singular Move, Threat Evaluation, Pawn Structure Evaluation, Move Legality Performance Improvement, Logarithmic LMR Based on QuietMoveNumber and ToHorizon, and evaluation of piece mobility, king safety (including x-ray moves), and threats using Safe Squares.

It also includes code quality improvements such as Color Agnostic Code, Removed Endgame King Safety Evaluation, Code Style Refactor (camelCased Method Parameters), Refactor Static Const to Enum, Reorganize Namespaces, and Remove Over-Counting NPS.

In addition, I fixed an Engine Hang Bug and an Invalid PV Bug.

You may download x64 and x86 versions of the engine from the Downloads page. Install the appropriate version for your computer’s CPU. The x64 binary is the strongest version of the engine.

I estimate MadChess 3.1 plays bullet chess at 2706 Elo and blitz chess at 2742 Elo.

Of course, you may decrease MadChess’ strength for a more enjoyable game via the UCI_LimitStrength and UCI_Elo engine options. Enjoy!

Now I’ll take a break from engine programming and actually play some chess. I’ll focus on improving my game (beyond patzer level) before the urge to improve MadChess’ game (to 2800 Elo) inevitably strikes.

 

Feature Category Date Commit1 WAC2 Elo Rating3 Improvement
Miscellaneous Improvements Evaluation 2022 Aug 30 6484a1b 287 2706 +19
Move Legality
Performance Improvement
Search 2022 Mar 18 533e382 289 2687 +36
Pawn Structure Evaluation 2022 Jan 11 d691b32 288 2651 +15
Threats Evaluation 2021 Oct 24 26e5323 289 2636 +7
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

Banks 95th Amateur Series Division 7

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

                               1    2    3    4    5    6    7    8    9    0    1    2    
1   Ceibo 0.9 64-bit           **** ½½10 ½111 1½½1 1½1½ ½11½ 1½11 1111 01½1 1½½½ ½011 1½11  33.0/44
2   Nawito 22.07 64-bit        ½½01 **** 1111 1½1½ 1½0½ 001½ 01½½ 1½1½ ½1½½ 10½1 001½ 1111  28.0/44
3   Lozza 2.4 64-bit           ½000 0000 **** ½1½1 1½½1 ½011 110½ 10½1 01½½ 1½01 0111 1101  24.5/44  491.75
4   Delocto 200419 64-bit      0½½0 0½0½ ½0½0 **** 0½01 ½½1½ 1½0½ 01½½ ½1½1 1111 111½ 1101  24.5/44  484.75
5   Blunder 8.5.5 64-bit       0½0½ 0½1½ 0½½0 1½10 **** ½0½½ ½½11 ½10½ ½½10 110½ 1111 ½½½1  24.0/44
6   Supernova 2.4 64-bit       ½00½ 110½ ½100 ½½0½ ½1½½ **** ½101 0001 11½0 0½10 ½111 ½½1½  22.5/44
7   Leorik 2.2 64-bit          0½00 10½½ 001½ 0½1½ ½½00 ½010 **** 1½½1 0½11 11½0 0011 ½½11  21.5/44
8   MadChess 3.0 64-bit        0000 0½0½ 01½0 10½½ ½01½ 1110 0½½0 **** 1000 1½11 0110 1½½1  20.0/44
9   RookieMonster t110 64-bit  10½0 ½0½½ 10½½ ½0½0 ½½01 00½1 1½00 0111 **** 0½0½ 1011 ½100  19.5/44
10  Betsabe II 2020            0½½½ 01½0 0½10 0000 001½ 1½01 00½1 0½00 1½1½ **** 0011 0011  17.5/44
11  Keele 1.0 64-bit           ½100 110½ 1000 000½ 0000 ½000 1100 1001 0100 1100 **** 1111  17.0/44
12  Loki 3.5.0 64-bit          0½00 0000 0010 0010 ½½½0 ½½0½ ½½00 0½½0 ½011 1100 0000 ****  12.0/44

Games