repetition detection using the TT

Discussion of chess software programming and technical issues.

Moderator: Ras

tcusr
Posts: 325
Joined: Tue Aug 31, 2021 10:32 pm
Full name: tcusr

repetition detection using the TT

Post by tcusr »

hi everyone, after a 3 months break i'm back on the development of my engine.
i'm adding repetition detection and i want to use this method.
basically i'm setting the flag in make move and unsetting it when undoing the move. i check if a position was seen in the probing section, before looking for a cutoff.
it doesn't work but beside that does anyone use this method? to my understanding it only works for repetitions in the tree, not the game history, and also there's the problem of entry collisions (mentioned in the wiki).
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: repetition detection using the TT

Post by lithander »

tcusr wrote: Tue Sep 06, 2022 11:14 pm to my understanding it only works for repetitions in the tree, not the game history, and also there's the problem of entry collisions (mentioned in the wiki).
I use the TT for repetitions from the game history. Basically I enter all positions from the history at an incredibly high depth and with a score of 0 before starting the search. The depth protects it against being overwritten.

Maybe you can also just not overwrite entries that have the flag set?
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: repetition detection using the TT

Post by hgm »

In Fairy-Max I use both these methods: upgrading the root entry to max depth and give it a draw score (inherited from micro-Max), and set a flag for open nodes in the tree (added in version 5.0). The latter is only important to plan for repetitions (e.g. sacrifice something to deliver a perpetual, when already behind, or prevent the opponont from doing this when ahead). It doesn't bring much Elo. Not repeating positions from the game history is essential; without that it becomes almost impossible to win, and very hard to test the effect of improvements.

Strictly speaking only positions that have occured twice in the game history should be put in the TT as max-depth draws.

In an SMP engine you would need one flag per thread, though. Which kind of spoils the idea, as it would require a larger TT entry. (While a single spare bit usually exists in those.)
tcusr
Posts: 325
Joined: Tue Aug 31, 2021 10:32 pm
Full name: tcusr

Re: repetition detection using the TT

Post by tcusr »

i really like this method, i thought that repetitions in the tree were as important.
thank you very much.
tcusr
Posts: 325
Joined: Tue Aug 31, 2021 10:32 pm
Full name: tcusr

Re: repetition detection using the TT

Post by tcusr »

lithander wrote: Tue Sep 06, 2022 11:49 pm
tcusr wrote: Tue Sep 06, 2022 11:14 pm to my understanding it only works for repetitions in the tree, not the game history, and also there's the problem of entry collisions (mentioned in the wiki).
I use the TT for repetitions from the game history. Basically I enter all positions from the history at an incredibly high depth and with a score of 0 before starting the search. The depth protects it against being overwritten.

Maybe you can also just not overwrite entries that have the flag set?
wait actually you don't even need to keep the history of the game.
just add a counter in the entry which is increased every time a "position" command is sent. if it equals to 2 you save the entry as a max depth draw.
meanwhile, in the tree, you don't overwrite the entries which have a count different than 0.