2

My engine is evaluating the same position at the same depth with a different score inside the search tree, is that normal?

[Title "depth 1   ply 3 alfa -20 beta -15  score -15 (1.Na3 a5 2.Nh3)"]
[FEN "rnbqkbnr/1ppppppp/8/p7/8/N6N/PPPPPPPP/R1BQKB1R w KQkq - 0 1"]

    [Title "depth 1   ply 3 alfa -20 beta -5  score -5 (1.Nh3 a5 2.Na3)"]
[FEN "rnbqkbnr/1ppppppp/8/p7/8/N6N/PPPPPPPP/R1BQKB1R w KQkq - 0 1"]

Search code:

        tab.makeMove(mov);
        // first  time eval value is -15 with alpha -30 beta -15 
        // second time eval value is -25 with alpha -30 beta -25
        // this is in the same search
        int eval = -negaMax(depth - 1, -beta, -alfa, ply + 1);
        tab.takeBack(mov);

        if (eval >= beta) {
            return beta;
        }

engine output:

go
info depth 1 score cp 50 pv b1c3 
info depth 2 score cp 0 pv b1c3 b8c6 
info depth 3 score cp 50 pv b1c3 b8c6 g1f3 
info depth 4 score cp 0 pv b1c3 b8c6 g1f3 g8f6 
info depth 5 score cp 40 pv b1c3 b8c6 d2d4 g8f6 g1f3 
info depth 6 score cp 0 pv b1c3 d7d5 d2d4 b8c6 g1f3 g8f6 
info depth 7 score cp 35 pv e2e4 b8c6 g1f3 g8f6 e4e5 f6e4 b1c3 
bestmove e2e4
6
  • Are you using a transposition table? Also, is there any randomness in your engine? Jun 2, 2020 at 20:54
  • No, there is no transposition table just alpha-beta pruning. The engine works fine. I tried to implement TT but I got many blunders for that reason I'm debugging and I found that the same position has different scores at the same depth in the search tree.
    – crrlos
    Jun 2, 2020 at 21:02
  • When you get a different score, are you letting the engine evaluate the position again after already evaluating it while it was running? Or are these on completely separate runs of the program? Jun 2, 2020 at 21:07
  • Yes, the engine evaluates the same position again. I added some code to help to understand where is the problem.
    – crrlos
    Jun 2, 2020 at 21:19
  • If that piece of code is executed twice in the same run of the program, I would guess you're altering static/global variables. Altering these on the first search could affect the second search. That's why I asked about a TT, since it's one example of static/global data. Jun 2, 2020 at 21:30

1 Answer 1

3

What you are seeing does not necessarily indicate a bug.

You are searching the position with two different bounds. Your engine is fail-hard (because you return beta and not eval in the case of a fail-high), so the score that comes back from eval is going to be constrained within the bounds you provide.

In the second case (using the numbers from your diagram, not your code) you are searching with a bounds of [-20, -5] and your score is -5. This is fine.

In the first case you are searching with a bounds of [-20, -15] and your score is -15. This is also fine. It would be impossible for this search to return a value of -5 because it is outside the bounds you provided.

In either case, what the search is telling you is that this position is better (relative to the side to move) than the bounds you provided because in both cases the search is failing high.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.