user24519: I read about the chess engine algorithms and came up with a question. If, for example  roughly all (disregarding alpha-beta pruning) possible 20 moves variations are calculated, why does a chess engine not consider a piece exchange on move 20 winning? It seems to me that to an evaluation function the final position will seem like one player is just up a piece. How do they solve this problem?

user924: Chess engines will always try to extend the search by a few moves, so a position is only evaluated if it is considered "quiet". This is called Quiescence Search, and the problem you describe that it is trying to prevent is called the "Horizon effect".
So before evaluating a position, if there are captures, checks and so on in the position, then the search is first extended by those moves.

24519: <p>I read about the chess engine algorithms and came up with a question. If, for example  roughly all (disregarding alpha-beta pruning) possible 20 moves variations are calculated, why does a chess engine not consider a piece exchange on move 20 winning? It seems to me that to an evaluation function the final position will seem like one player is just up a piece. How do they solve this problem?</p>
 924: <p>Chess engines will always try to extend the search by a few moves, so a position is only evaluated if it is considered &quot;quiet&quot;. This is called <a href="https://www.chessprogramming.org/Quiescence_Search" rel="noreferrer">Quiescence Search</a>, and the problem you describe that it is trying to prevent is called the &quot;Horizon effect&quot;.</p>
<p>So before evaluating a position, if there are captures, checks and so on in the position, then the search is first extended by those moves.</p>
