Threefold repetition and transposition table
Posted: Thu Jan 09, 2014 9:52 pm
Hi! I am writing my own engine, and i have just implemented transposition table, and now i have a problem with threefold repetion.
This is a snippet from my alphabeta function:
In my transposition table i use "replace if deeper" replacement scheme. The problem is: When a position is encountered for a first time, and it is evaluated, result is written into transposition table. Later, when the position happens for a second time on board, program takes previously calculated value from transposition table and returns it, without being aware of danger of draw, when he realizes that a draw will happen, it is far too late. This is clearly visible during endgame, when program is trying to checkmate opponent, he can easly force a draw because of threefold repetition.
I've been thinking about this for a while but i haven't came up with anything. Can you please give me some hints how to deal with this problem?
This is a snippet from my alphabeta function:
Code: Select all
if (CountRepetitions(currentBoardHash) >= 3) // threefold repetition
return DRAW;
int tableScore = transpositionTable.getScore(currentBoardHash, depth, alpha, beta)
if (tableScore != UNKNOW_VALUE)
return (tableScore)
I've been thinking about this for a while but i haven't came up with anything. Can you please give me some hints how to deal with this problem?