Skip to content

Commit

Permalink
Make fold a tt key condition
Browse files Browse the repository at this point in the history
Unlike Stockfish, Pikafish allows some extensions of 2 folds to guard the engine against false mates. However, this brings more instability to the Transposition Table. For example, positions never occured before or positions already occured in the history share the same tt entry and it causes some false mates problems. This is known as the notorious Graph History Interaction. (3annR1N/3PaP1P1/1P1Pbk2b/pCp1p1c1N/9/6B2/1r1R1c3/3AB1C2/3pAp2r/4K4 w - - 0 1)

To mitigate this issue, we xor keys with the folding information to allow positions with and without occurance history to be reside in different tt entries thus makes the engine more rubust against false mates bring by tt instability.

Note that eleeye do have some technology against this, but the detection is too costly, while this implementation is simpler and with almost no extra cost expect for additional tt entry spent.

Idea by PikaCat++

Task: make fold a tt condition
Book: winrate 65_85

Passed STC:
TC: 10+0.1
Total/Win/Draw/Lose: 41832 / 10534 / 21086 / 10212
PTNML: 236 / 4675 / 10758 / 5025 / 222
WinRate: 50.38%
ELO: 2.44[0.60, 4.24]
LOS: 99.50
LLR: 2.92[-2.94, 2.94]

Passed VLTC
TC: 180+1.8
Total/Win/Draw/Lose: 11950 / 3012 / 6103 / 2835
PTNML: 5 / 1100 / 3585 / 1283 / 2
WinRate: 50.74%
ELO: 4.91[2.06, 7.74]
LOS: 99.96
LLR: 2.93[-2.94, 2.94]
  • Loading branch information
PikaCat-OuO committed Nov 14, 2024
1 parent 384ae4a commit 292ea96
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ inline Key Position::key() const { return adjust_key60<false>(st->key); }

template<bool AfterMove>
inline Key Position::adjust_key60(Key k) const {
return st->rule60 < 14 - AfterMove ? k : k ^ make_key((st->rule60 - (14 - AfterMove)) / 8);
return (st->rule60 < 14 - AfterMove ? k : k ^ make_key((st->rule60 - (14 - AfterMove)) / 8))
^ (filter[st->key] ? make_key(14) : 0);
}

inline Key Position::pawn_key() const { return st->pawnKey; }
Expand Down

0 comments on commit 292ea96

Please sign in to comment.