Added transposition table (this was tested alone and worked as expected), three fold repetition and null move pruning in my engine and wins more games but some of them end with three fold repetition even in win positions, played against the previous version
I keep a table history to save the current state of the board before making the move, to save the current zobrist key, move, en passant and castling
In make null function I just hash the en passant if exists, switch side, hash it and increment the fiftymove counter
To check for repetitions I do this:
int i;
for (i = 4; i <= board->fiifty_move; i += 2) {
if (board->zkey == board->history[board->ply - i].zkey) {
return true;
}
}
The question is when checking for repetition it will check also for null move positions, is that correct? If a null move is repeated can we take that as a move even that null move it just switching sides?
I've seen engines that has a array like: hist_rep[index++].zkey = curr_zkey;
that is only to check for repetitions and the array is not filled in the make null move function
Others engines has a counter inside the repetition function to check if the position has been repeated before more than one time
for (...) {
if (zkey[i] == curr_zkey) ++rep;
if (rep == 2) return true;
}
What is the correct way?