My engine it's based on Vice: https://chessprogramming.wikispaces.com/Vice
I learned many things watching the videos and coding
But trying to get better results I modified a part that was wrong(?) in the code, take a look this part in the file search.c in the AlphaBeta function:
Code: Select all
if(Score > BestScore) {
BestScore = Score;
BestMove = list->moves[MoveNum].move;
if(Score > alpha) {
if(Score >= beta) {
if(Legal==1) {
info->fhf++;
}
info->fh++;
if(!(list->moves[MoveNum].move & MFLAGCAP)) {
pos->searchKillers[1][pos->ply] = pos->searchKillers[0][pos->ply];
pos->searchKillers[0][pos->ply] = list->moves[MoveNum].move;
}
StoreHashEntry(pos, list->moves[MoveNum].move, beta, HFBETA, depth);
return beta;
}
alpha = Score;
if(!(list->moves[MoveNum].move & MFLAGCAP)) {
pos->searchHistory[pos->pieces[FROMSQ(list->moves[MoveNum].move)]][TOSQ(list->moves[MoveNum].move)] += depth;
}
}
}
// ....................
if(alpha != OldAlpha) {
StoreHashEntry(pos, BestMove, BestScore, HFEXACT, depth);
} else {
StoreHashEntry(pos, BestMove, alpha, HFALPHA, depth);
}
And in the end of the AlphaBeta function you can see when alpha is not improved, it saves the BestMove in the TT:
Code: Select all
if(alpha != OldAlpha) {
StoreHashEntry(pos, BestMove, BestScore, HFEXACT, depth);
} else {
StoreHashEntry(pos, BestMove, alpha, HFALPHA, depth); // <-- Here!
}
5s + 100ms 5000 games
Code: Select all
Program Elo + - Games Score Av.Op. Draws
1 Vice10 x64 : 1404 8 8 5000 51.3 % 1396 27.7 %
2 Vice10 x64 BM : 1396 8 8 5000 48.7 % 1404 27.7 %
Individual statistics:
1 Vice10 x64 : 1409 1297 (+449,=464,-384), 52.5 %
Vice10 x64 BM : 1297 (+449,=464,-384), 52.5 %
2 Vice10 x64 BM : 1391 1297 (+384,=464,-449), 47.5 %
Vice10 x64 : 1297 (+384,=464,-449), 47.5 %
Code: Select all
Program Elo + - Games Score Av.Op. Draws
1 Vice10 x64 : 1409 15 15 1297 52.5 % 1391 35.8 %
2 Vice10 x64 BM : 1391 15 15 1297 47.5 % 1409 35.8 %
Individual statistics:
1 Vice10 x64 : 1409 1297 (+449,=464,-384), 52.5 %
Vice10 x64 BM : 1297 (+449,=464,-384), 52.5 %
2 Vice10 x64 BM : 1391 1297 (+384,=464,-449), 47.5 %
Vice10 x64 : 1297 (+384,=464,-449), 47.5 %
I tested using cutechess and for the opening 10-PGN-Books\2moves_v1.pgn
I've looked some engines sources and all set the bestmove var inside score > alpha
What is wrong?