How do chess engines evaluate a position if the position is in the middle of an exchange? In the minimax algorithm, chess engines do a depth-first search as far as they can calculate ahead, and then evaluate all these final positions. Then, using these evaluations they work backwards one move at a time and assign values to the previous positions. Eventually they reach the current, starting position and give it an evaluation value.

However, how would minimax chess engines evaluate a final position if it was in the middle of some exchange? For example, take the following:


e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Bxc6


Let's say an engine's depth capacity was 7 ply (a move from either player), and it reached this position as one of the final positions in its calculations from the start of the game. It wouldn't be able to calculate further (and see Black could play 4...dxc6) and would have to evaluate this position now. To me, it seems it would have to assign this final position a +3 advantage for White, but I know that chess engines have a way around this.

My question is, how do chess engines get around this scenario?
A good chess engine won't stop after a predetermined number of moves, but will keep looking until the position is "quiescent", which roughly speaking means that there are no pending captures or checks. See Quiescence Search in chessprogramming wikispaces for a more detailed explanation.