Rather than repeat myself, I’ll explain my recent code update by copying the text of my Pull Request #10 here:
Improved detection of pieces pinned to own king by sliding attackers. Previous implementation only found potentially pinned pieces (because the pieces were on the same file, rank, or diagonal as the sliding attacker). The new implementation finds all actually pinned pieces.
This speeds up resolution of pseudo-legal moves to legal moves by eliminating unnecessary calls to
Board.IsMoveLegal method. Its benefit is limited though because many pseudo-legal moves never are examined for legality because a beta cutoff occurs before the move is searched.
Eliminated unnecessary call to
Board.IsMoveLegal method. Instead of actually making a null move, the code flips side-to-move, sets a few other properties of the position, calls
IsSquareAttacked(kingSquare), then restores original property values.
I experimented with eliminating the remaining call to
Board.IsMoveLegal method to determine if this speeds up resolution of pseudo-legal moves to legal moves. I did this by intersecting pre-calculated moves from the destination (To) square to the opponent king. And by detecting pieces pinned to the opponent king by own sliding attackers. Moving such pieces in a direction other than the attacking ray creates a discovered check. Unfortunately, this code was slower than simply moving the piece and calling
Board.IsSquareAttacked uses pre-calculated moves (magic bitboards) to determine if own king is attacked after moving the piece, constituting an illegal move. Did not include in this PR.
Also, I experimented combining legality checking with playing a move in a
Board.PlayMoveIfLegal method. Unfortunately this causes numerous complications with futility-pruned moves. MadChess never prunes moves that deliver check, moves aren’t known to deliver check until they’re played, so this must be detected after the fact (which complicates undoing the move and restoring board state) or detected prior to playing the move (which already has been proven slower). Ugly and prone to bugs. Did not include in this PR.
Also adjusted how nodes are counted- affecting Node Per Second (NPS) metric- to a more honest measurement. A node is counted only in…
Board.PlayNullMovemethod (because this changes side-to-move plus a few other properties and advances position index)
2562 +/- 16 ELO at bullet chess.
|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