MadChess 2.0 Beta Build 027 (Draw By Repetition Bug)

Yes! I found and exterminated the bug I mentioned in my previous post.

I corrected a bug that caused MadChess to play a losing move in a drawn by repetition position. MadChess evaluates the first repetition of a position as drawn, even though the rules of chess state the second repetition is drawn. This search optimization avoids wasting a ply to determine the position is drawn by repetition.

MadChess’ recursive search method checks if a position is repeated before searching any moves. If the position is a repeat of an earlier position, the search returns a zero score.

I forgot to prevent MadChess from considering the root position as drawn. If the root position was drawn, the game would be over and MadChess would have nothing to search. It’s not legally drawn. MadChess considers it drawn due to a search optimization. Because MadChess considers the root position drawn, it does not search any root moves. The score of each root move remains -Score.Max, which represents the nonsensical mate in zero I mentioned in my previous post. Because each move is considered equal, essentially a random move is played. Since many drawn by repetition positions are dependent on a single move that holds the draw, this bug often caused MadChess to play a losing move.

The bug fix was trivial.

This added 47 ELO to the playing strength of MadChess 2.0 Beta.

MadChess 2.0                   1813 :    800 (+161,=104,-535),  26.6 %

vs.                                 :  games (   +,   =,   -),   (%) :   Diff,  SD, CFS (%)
BikJump v2.01                       :    100 (  10,  11,  79),  15.5 :   -270,  13,    0.0
Matheus-2.3                         :    100 (  10,   7,  83),  13.5 :   -256,  13,    0.0
Monarch 1.7                         :    100 (  13,  13,  74),  19.5 :   -226,  14,    0.0
BigLion 2.23w                       :    100 (  27,   7,  66),  30.5 :   -193,  13,    0.0
Faile 1.4                           :    100 (  17,  20,  63),  27.0 :   -187,  12,    0.0
Sharper 0.17                        :    100 (  26,  18,  56),  35.0 :   -173,  13,    0.0
Jabba13032012                       :    100 (  33,  13,  54),  39.5 :   -116,  12,    0.0
Roce 0.0390                         :    100 (  25,  15,  60),  32.5 :    -47,  12,    0.0
Feature Category Date Build Number WAC1 ELO Rating2 Improvement
Draw By Repetition Bug Evaluation 2014 Dec 10 27 225 1813 +47
Passed Pawns Evaluation 2014 Dec 09 26 225 1766 +72
Time Management Search 2014 Dec 08 25 231 1694 +24
Delay Move Generation
Aspiration Window Bug
Search 2014 Dec 02 23 231 1670 +44
MVV / LVA Move Order
Draw By Insufficient Material
Move List Overflow Bug
Search 2014 Dec 01 22 235 1626 +30
Tapered Evaluation
MG and EG Piece Location
Evaluation 2014 Nov 29 21 234 1596 +107
Alpha / Beta Negamax
Aspiration Windows
Quiescence, Hash
Material, Piece Squares
Baseline 2014 Nov 25 20 236 1489
  1. Win At Chess position test, 3 seconds per position
  2. Bullet chess, 2 min / game + 1 sec / move
Bookmark the permalink.

2 Comments

  1. I’m developing a chess engine (MORA Chess Engine) and yesterday while it was playing against another engine it had a winning position but it played a senseless move. I thought the problem was related to transposition tables but after reading this I think I have the same bug you had, thanks for this post!

  2. I’m glad my blog post was helpful! That’s a subtle bug to chase down.

Leave a Reply

Your email address will not be published. Required fields are marked *