user23554: 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


user23985: 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.

23554: <p>My engine is evaluating the same position at the same depth with a different score inside the search tree, is that normal?</p>

<pre><code>[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"]
</code></pre>

<hr>

<pre><code>    [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"]
</code></pre>

<p><strong>Search code:</strong></p>

<pre><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 &gt;= beta) {
            return beta;
        }
</code></pre>

<p><strong>engine output:</strong></p>

<pre><code>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
</code></pre>
 23985: <p>What you are seeing does not necessarily indicate a bug.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
