In order to calculate far ahead, minimax chess engines must perform alpha-beta pruning, where they don't calculate positions that are obviously winning or obviously losing. Without doing pruning, engines would have to deal with over a billion positions in the first 4 moves / 8 ply of the game.
My question is how do minimax engines perform alpha-beta pruning without evaluating the final positions? How does an engine know whether a position is completely won / lost without calculating as deep as it can go? For example:
- e4 e5 2. Nf3 d6 3. Bc4 Bg4 4. Nc3 Nc6 5. h3 Bh5 6. Nxe5 Bxd1
At this point, White's two moves away from checkmate. Assuming the engine wasn't aware of the Legal's Mate, wouldn't it apply Alpha-Beta pruning and just stop calculating at this point, assuming the position is won for Black?
I'm aware of quiescence search, where the engine won't stop calculating until the position is considered "quiet". In this position, White is able to play Bxf7+ and Black's King is in danger, so this position wouldn't qualify as a quiet position.
But if an engine has to perform quiescence search everytime it needs to decide whether to perform Alpha-Beta pruning and stop calculating further, doesn't this defeat the purpose of pruning in the first place? Since you need to calculate ahead to check to see if you don't need to calculate ahead.
EDIT: There are two answers to this question that I found very useful. Look at SmallChess' answer for info on issues with the depth-limit of engines' calculations. See RemcoGerlich's answer for an excellent description of what Alpha-Beta pruning is. When I wrote this question I didn't truly know what it was.