10

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?

Rewan Demontay
  • 16,942
  • 4
  • 65
  • 109
Nick
  • 111
  • 5
  • 1
    Note that when an engine says it's at some depth (say depth 25), this includes the quiescence search Remco mentioned in his answer. An engine at depth 25 could still be going only 25 plies deep for certain variations, while at the same time 30 plies deep for others. – Inertial Ignorance Aug 22 '20 at 05:35
  • You may be interested in [this detailed explanation about the basics of how a general chess engine works](https://chess.stackexchange.com/a/29842/9192). – user21820 Aug 22 '20 at 15:48

1 Answers1

25

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.

RemcoGerlich
  • 27,663
  • 78
  • 120
  • Due to the Halting Problem it seems like a weakness whereby one could detain a chess engine by pursuing a line that is very "noisy" for many moves, thereby making it waste time getting into deeper plys. – Michael Aug 22 '20 at 17:00
  • One might suspect that "very noisy" situations often (seem to?) resolve fairly quickly? – paul garrett Aug 22 '20 at 17:46
  • Well time spent is an issue (that page I linked to says that 50% - 90% of total nodes searched are nodes added for quiescence search!) but I have no idea why the halting problem would matter. It always halts, the game is finite. – RemcoGerlich Aug 22 '20 at 17:47
  • This answer could be improved by including the definitions of "quiet" and the "Horizon effect" in the answer itself, since those are a core part of the answer. – NotThatGuy Aug 23 '20 at 02:35
  • 2
    It has nothing really to do with the halting problem. As for trying to "confuse" the chess engine, to properly do that you would need to be able to match it's calculating depth... – Erik Aug 23 '20 at 12:38