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.
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.
- PR 18: Remove Endgame King Safety Evaluation
- PR 19: Code Style Refactor (camelCased Method Parameters)
- PR 20: Refactor Static Const to Enum
- PR 21: Reorganize Namespaces
- PR 22: Eliminate Color-Specific Code
Combined, the five PRs removed 350 lines of code. This increased the playing strength of MadChess 3.1 Beta by 12 Elo.
|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|
Material and Piece Location
|Baseline||2018 Nov 08||58||269||2096||0|
- GitHub commit (hash) or Subversion source code revision (integer)
- Win At Chess position test, 3 seconds per position
- Bullet chess, 2 min / game + 1 sec / move