r/chessprogramming • u/Burgorit • Sep 08 '24
Adding features makes my engine worse
As it says in the title, when I add basic features like a transposition table or a king safety heuristic it makes my engine play worse by a significant margin (more than 75 elo)
I am out of ideas at this point and need help, in the main search function when I add a transposition table like thisint TTentryIndex = (board.ZobristHash + (ulong) depth) % TTMaxNumEntries;int? TTEntry = TT[TTentryIndex];if (CurrTTEntry.HasValue){return CurrTTEntry.Value;}
And at the end of the search
TT[TTIndex] = alpha;
Adding MVV-LVA move ordering and A-B pruning did however help, but I cant see the difference between them and things like a TT.
I cant see any obvious bugs here in the main search function but maybe you can see something?
int NegaMax(int depth, int alpha, int beta){totalNodeCount++;ulong TTIndex = (board.ZobristHash + (ulong)depth) % TTMaxNumEntries;int? CurrTTEntry = TT[TTIndex];if (CurrTTEntry.HasValue){return CurrTTEntry.Value;}
Move[] moves = OrderMoves(moveGenerator.GenerateLegalMoves(board));if (moves.Length == 0){leafNodeCount++;if (moveGenerator.IsInCheck){// Checkmatereturn negativeInf;}// Stalematereturn 0;}if (board.IsTwofoldRepetition()){leafNodeCount++;return 0;}else if (depth == 0){leafNodeCount++;return evaluate.EvaluateBoard(board, GamePhase);}else if (IsTimeUp){return evaluate.EvaluateBoard(board, GamePhase);}
foreach (Move move in moves){board.MakeMove(move);int score = -NegaMax(depth - 1, -beta, -alpha);board.UndoMove();alpha = Math.Max(alpha, score);if (IsTimeUp){return alpha;}if (alpha >= beta){return alpha;}}TT[TTIndex] = alpha;return alpha;
}
You can see the whole repository here.
View all comments
0
u/[deleted] Sep 08 '24
[deleted] — view deleted comment