Shifting Focus

Those of you who’ve written a chess engine understand how difficult it is to refrain from tinkering with the code. One always has ideas for more efficient algorithms or more concise code. These ideas need expression, need testing and verification. But at some point, due to the cruel law of diminishing returns, one has to walk away and work on other problems.

I feel I’ve reached that point. I’d like to shift my focus from improving the playing strength of MadChess to writing a Graphical User Interface (GUI). To that end, I spent time today reading about the latest Microsoft technologies for building Windows applications. I’m not entirely sure, but I believe I’ll use Windows Presentation Foundation (WPF). I like the combination of XML markup (for positioning / styling user interface controls) and C# code (for handling user input and implementing the application logic).

Plus, WPF provides a ribbon control. This evening I managed to construct a basic WPF application with a ribbon.

Now I need to make a list of chess GUI features I’d like to implement. And prioritize the list. Then start replacing the bogus buttons in the basic WPF application with chess buttons and chess features…

Update a few weeks later: In case you’re wondering, I never pursued this. Went back to programming my chess engine (not a GUI).

Testing MadChess 1.3

I am testing MadChess 1.3 at rapid time controls (15 min / game + 10 sec / move). You can follow the games on the Live Games page.

I’m running four instances of the Shredder GUI. I wrote a script to transfer tournament standings and games to this website, using the Windows FTP command line utility. I registered a task in the Windows Task Scheduler to run the script every five minutes.

Earlier I tested MadChess 1.3 at faster time controls and got these results:

  • Bullet ( 2 min / game +  1 sec / move): 2153 +/- 22 ELO
  • Blitz  ( 5 min / game +  3 sec / move): 2234 +/- 22 ELO
  • Rapid  (15 min / game + 10 sec / move): 2313 +/- 26 ELO

Update May 25: I stopped the match at 500 games. These tests indicate MadChess’ strength increases (relative to the same opponents) as the time control increases.

MadChess 1.2 Released

I’ve managed to add another 100+ ELO to MadChess. I estimate MadChess’ playing strength is ~ 2090 ELO at bullet time control. At blitz, I estimate its strength is ~ 2140 ELO. The strength improvement is mostly due to more efficient move generation and an improved principal variation search algorithm. Those and other more cosmetic changes are detailed below.

Source code and EXEs available on the Downloads page.

  1. Implemented a check evasion move selector.
  2. Improved principal variation search algorithm.
  3. Improved efficiency of aspiration windows. Window is increased in configurable steps instead of doubling.
  4. Decreased positional bonuses.
  5. Added bonuses for backward pawns, connected rooks (on file) and good attacks (attacks of greater value pieces).
  6. Updated pawn endgame location values to encourage pawn pushes.
  7. Improved time management of classical time controls (x moves in y seconds).
  8. Improved memory usage of position cache.
  9. Decreased allocations of move collection classes during search.
  10. Removed duplicate search code at root node. Consolidated into a single search method.
  11. Removed duplicate pawn promotion and en passant code. Consolidated into pawn class.
  12. Added debug code to detect move generation errors.

MadChess 1.1 Released

I’ve made many changes to MadChess, detailed below. I tested at my usual bullet time control (2 min + 1 sec / move) and found only a 30 ELO gain, a bit disappointing for so many changes. However, informal testing at 40 moves in 4 min shows a much larger gain- potentially 60 ELO. This makes sense because my engine is a relatively slow searcher. Perhaps the CCRL testers can verify?

I removed 174 lines of code and gained 30 ELO. At this rate, if I remove all the code my engine will play with super Grandmaster strength, ha ha!

Source code and EXEs available on the Downloads page.

  1. Added tapered evaluation.
    1. Calculate static score for middlegame and endgame.
    2. Determine game phase from material on board.
    3. Calculate weighted average of middlegame and endgame static scores.
    4. This eliminates the discontinuity of a sudden jump from middlegame to endgame static scores.
    5. Static score slowly tapers from middlegame to endgame.
  2. Moved piece location values (aka piece square tables) to text files and made configurable via a UCI option.
  3. Separated passed pawn static score into middlegame score and endgame score.
  4. Added knight mobility static score.
  5. Separated piece mobility static scores into middlegame mobility and endgame mobility.
  6. Improved evaluation of king safety, especially evaluation of coordination of attacking pieces.
  7. Eliminated Reduce Pawn Push, Reduce Capture, Reduce Killer Move, Reduce In Check, and Reduce Check UCI options.  (All reductions disallowed.)
  8. Eliminated all reductions and lazy evaluation in principal variation.
  9. Simplified late move reductions.
  10. Added Reduce Root UCI option (default = false).
  11. Improved performance of Score Inaccuracy code. Renamed UCI option from Score Inaccuracy to Score Error.
  12. Added a UCI option, Max Nodes Per Second, to throttle search speed. Eliminated Evaluation Delay UCI option.
  13. Consult best move cache in main search and quiet search instead of only in main search.
  14. Age values in history cache when receiving new position (reduce 90%) and during search (reduce 50% if value exceeds maximum).
  15. Eliminated Middlegame Time Factor UCI option. (All moves given equal time.)
  16. Improved time management, especially for traditional time controls (such as 40 moves in 4 minutes).  Interrupt if ply takes four times longer than expected to search.
  17. Refactored code.
    1. Removed 174 lines of code.
    2. Rewrote to comply with Microsoft managed recommended rules.
    3. Rewrote to comply with JetBrains ReSharper default rules.

MadChess 1.0 Released

I have renamed my chess program. Considering my family name is Madsen, I went with the obvious: MadChess.

MadChess 1.0 is 150 ELO stronger than its predecessor, RumbleMinze 1.0.33. MadChess 1.0 is nearly equal in strength to MicroMax 4.8 and Roce 0.0390 in bullet chess (2 min / game + 1 sec / move). It is slightly weaker than Faile 1.4.

Most of the strength increase is due to incremental move generation (using the C# yield statement) and an incrementally updated list of attackers for any rank, file, upward diagonal, or downward diagonal. This speeds up capture generation and check detection. See TalkChess for details. Some strength was gained by fixing a bug involving storing / retrieving mate scores in the hashtable.

Source code and EXEs available on the Downloads page.