Answers.Body: <p>Engines don't use "infinity", usually they provide the value of position in centi-pawns, a queen will cost about 1000 centi-pawns and the price of the king is something about 30000 centi-pawns. When you are close to the mate, you get the evaluation at around 30000 minus about 1 queen for every move to reach the mate, to make it reasonable to sacrifice the queen for delaying the mate.</p>
  
  <p>"mate in 1" becomes 29000, "mate in 2" becomes 28000 an so on, so engine has quite clear picture which move to make.</p>
  
  <p>And reaching "mate in 10" only makes the engine to prune all branches that evaluate in anything less valuable, so "mate in 8" still stays on the table.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-22T17:06:13.807Z
Answers.LastActivityDate: 2018-06-22T17:06:13.807Z
Answers.UserDisplayName: lenik
Body: <p>According to an engine, a mate in X moves = +infinity, since it is a forced win for it.</p>
  
  <p>Also according to an engine, a mate in X+Y moves = +infinity, since it's a forced win (just more moves, but an engine doesn't care about this).</p>
  
  <p>Due to the pruning in the minimax algorithm, if the engine first examines the "mate in X+Y moves" branch, it will see it's a forced win and then prune all the other branches.</p>
  
  <p>Due to this pruning, it wouldn't examine the mate in X moves branch.</p>
  
  <p>However, engines like Stockfish always rank a mate in X moves above a mate in X+Y moves. I refuse to believe these engines <em>always</em> know intuitively which branch to look at first (if this was the case, then the engines would first look at the mate in X moves branch first, and then prune the rest, which would make sense).</p>
  
  <p><strong>Question</strong>: Given this, how do engines always rank a forced win/mate in X above a forced  win/mate in X+Y, if they sometimes look at the latter first?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-21T21:30:46.003Z
Comments.Text: Not an answer to your question, but I believe that engines don't evaluate a mate as +infinity but as some (large)  finite number.
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-21T21:32:47.453Z
Comments.Text: I think your premise is flawed.  I sometimes see the engine declare a mate in 15, think for a few seconds, and then declare a mate in 12 instead. Obviously it didn't look at the best branch first, but considered it later.
Comments.UserDisplayName: D M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-22T01:17:19.693Z
Comments.Text: @user1583209 Agreed, I was just using "infinity" as a theoretical value.
Comments.UserDisplayName: Inertial Ignorance
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-22T01:18:31.880Z
Comments.Text: @D M Okay, that makes sense. I just couldn't remember seeing that, so I thought it was odd.
Comments.UserDisplayName: Inertial Ignorance
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-22T02:35:25.420Z
Comments.Text: When a computer finds a mate in X, it returns (INF - X).  This allows it to keep track of of number of move til mate and to return a better value.  If you use Iterative deepening, the first mate found is the shortest mate. Note:  INF is a high number and may be negative for black mating, so the formula would change to -INF + X.
Comments.UserDisplayName: Fred Knight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-22T04:32:20.213Z
Comments.Text: @Fred Knight The minimax algorithm is most efficient with a depth-first search of branches though, not a breadth-first/iterative deepening search. This allows it to prune branches (via alpha-beta pruning) that are guaranteed to not beat a previous branch.
Comments.UserDisplayName: Inertial Ignorance
Tags: <engines><checkmate><stockfish><evaluation><calculation>
Title: How are chess engines able to rank a Mate in X above a Mate in X+Y?
ThreadText: # How are chess engines able to rank a Mate in X above a Mate in X+Y?
  
  (Asked by: username_0 on 2018-06-21)
  
  According to an engine, a mate in X moves = +infinity, since it is a forced win for it.
  
  Also according to an engine, a mate in X+Y moves = +infinity, since it's a forced win (just more moves, but an engine doesn't care about this).
  
  Due to the pruning in the minimax algorithm, if the engine first examines the "mate in X+Y moves" branch, it will see it's a forced win and then prune all the other branches.
  
  Due to this pruning, it wouldn't examine the mate in X moves branch.
  
  However, engines like Stockfish always rank a mate in X moves above a mate in X+Y moves. I refuse to believe these engines *always* know intuitively which branch to look at first (if this was the case, then the engines would first look at the mate in X moves branch first, and then prune the rest, which would make sense).
  
  **Question**: Given this, how do engines always rank a forced win/mate in X above a forced win/mate in X+Y, if they sometimes look at the latter first?
  
  **Tags:** engines, checkmate, stockfish, evaluation, calculation
  
  > **Comments:**
  > **username_1**: Not an answer to your question, but I believe that engines don't evaluate a mate as +infinity but as some (large)  finite number.  
  > **username_2**: I think your premise is flawed.  I sometimes see the engine declare a mate in 15, think for a few seconds, and then declare a mate in 12 instead. Obviously it didn't look at the best branch first, but considered it later.  
  > **username_0**: @username_1 Agreed, I was just using "infinity" as a theoretical value.  
  > **username_0**: @username_2 Okay, that makes sense. I just couldn't remember seeing that, so I thought it was odd.  
  > **username_3**: When a computer finds a mate in X, it returns (INF - X).  This allows it to keep track of of number of move til mate and to return a better value.  If you use Iterative deepening, the first mate found is the shortest mate. Note:  INF is a high number and may be negative for black mating, so the formula would change to -INF + X.  
  > **username_0**: @username_3 The minimax algorithm is most efficient with a depth-first search of branches though, not a breadth-first/iterative deepening search. This allows it to prune branches (via alpha-beta pruning) that are guaranteed to not beat a previous branch.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2018-06-22. Score: 3 | Accepted answer
  
  Engines don't use "infinity", usually they provide the value of position in centi-pawns, a queen will cost about 1000 centi-pawns and the price of the king is something about 30000 centi-pawns. When you are close to the mate, you get the evaluation at around 30000 minus about 1 queen for every move to reach the mate, to make it reasonable to sacrifice the queen for delaying the mate.
  
  "mate in 1" becomes 29000, "mate in 2" becomes 28000 an so on, so engine has quite clear picture which move to make.
  
  And reaching "mate in 10" only makes the engine to prune all branches that evaluate in anything less valuable, so "mate in 8" still stays on the table.
  
  
  ---
  
  