Answers.Body: <p>As far as I can tell, you are crystal clear conceptually, and you aren't actually missing anything. I think the source of any apparent conflict between your understanding and the quoted passage is that you may be reading the passage to be claiming more than it really is. Here it is again, with some added emphasis:</p>
  
  <blockquote>
    <p>Say it is White's turn to move, and <strong>we are searching to a depth of 2</strong> (that is, we are consider all of White's moves, and all of Black's responses to each of those moves.) First we pick one of White's possible moves - let's call this Possible Move #1. We consider this move and every possible response to this move by black. After this analysis, we determine that the result of making Possible Move #1 is an even position. Then, we move on and consider another of White's possible moves (Possible Move #2.) When we consider the first possible counter-move by black, we discover that playing this results in black winning a Rook! In this situation, <strong>we can safely ignore all of Black's other possible responses to Possible Move #2 because we already know that Possible Move #1 is better</strong>.</p>
  </blockquote>
  
  <p>I think that the only point being made here is that in this particular situation, "we already know that Possible Move #1 is better" <em>as far as our limited depth search is concerned</em>. That is, we have fixed this depth of 2 ply for our search in advance, that is as far as our knowledge is going to go, and the information discovered in the scenario does conclusively show that <em>within the scope of the next 2 plies</em> Possible Move #1 is better than Possible Move #2.</p>
  
  <p>Your worry that something crucial might be being missed beyond that limit is absolutely correct, of course, and is why ideally such an algorithm would search all the way to the end of the entire chess game tree. That would be the only way to know that we have no "unsafe pruning," or in other words that we are playing optimally. But going that far isn't feasible (except for e.g. certain endgame positions, as you note, or say positions that are close to a forced conclusion of a game), so in whatever reasonable, finite amount of time an engine will have to search, it will only make it to some particular depth N that is insufficient for complete certainty. The point being made in the above passage isn't that we know Possible Move #1 is <em>truly</em> better than Possible Move #2 (i.e. with respect to the entire game tree), but only that we know it is definitely better with respect to the fixed depth N we actually get to search. But that's OK, as that's all we could possibly be sure of, which is exactly your point.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-15T00:49:14.933Z
Answers.LastActivityDate: 2014-03-15T00:49:14.933Z
Answers.UserDisplayName: ETD
Body: <p>I'm writing a simple chess program from scratch on a hobbyist basis. I think there is something fundamental I'm overlooking or don't understand.</p>
  
  <p>I read the following <a href="http://chessprogramming.wikispaces.com/Alpha-Beta" rel="noreferrer">http://chessprogramming.wikispaces.com/Alpha-Beta</a>, as well as other articles, e.g. the Wikipedia one. I've also implemented alpha-beta blindly before just by following pseudo-code. I believe I understand how alpha-beta can guarantee no unsafe pruning takes place on a complete search tree, i.e. if you have the whole search tree, and there are no unexplored nodes beyond the horizon.</p>
  
  <p>What I don't understand is how alpha-beta can guarantee no unsafe pruning takes place on an <em>incomplete search tree</em> which does contain such unexplored nodes beyond the horizon, which chess always results in, unless evaluating endgames with a small enough tree.</p>
  
  <p>Consider the following explanation from: <a href="http://chessprogramming.wikispaces.com/Alpha-Beta" rel="noreferrer">http://chessprogramming.wikispaces.com/Alpha-Beta</a></p>
  
  <blockquote>
    <p>Say it is White's turn to move, and we are searching to a depth of 2
    (that is, we are consider all of White's moves, and all of Black's
    responses to each of those moves.) First we pick one of White's
    possible moves - let's call this Possible Move #1. We consider this
    move and every possible response to this move by black. After this
    analysis, we determine that the result of making Possible Move #1 is
    an even position. Then, we move on and consider another of White's
    possible moves (Possible Move #2.) When we consider the first possible
    counter-move by black, we discover that playing this results in black
    winning a Rook! In this situation, we can safely ignore all of Black's
    other possible responses to Possible Move #2 because we already know
    that Possible Move #1 is better.</p>
  </blockquote>
  
  <p>This seems to be false to me, exploring further nodes on the branch of "Possible Move" #2, e.g. a couple more ply, could result in black being guaranteed checkmate?</p>
  
  <p>Hence pruning away this as a possible move is not safe.</p>
  
  <p>What am I missing?</p>
  
  <p>I know this ties in with the horizon effect and quiescence search, however I don't understand how alpha-beta alone, when used in this way on an incomplete search tree can be considered "safe". But I'm sure there is something I'm overlooking and it would be great with some pointers.</p>
  
Tags: <engines><chess-algorithms>
Title: Alpha-beta safe on incomplete tree?
ThreadText: # Alpha-beta safe on incomplete tree?
  
  (Asked by: username_0 on 2014-03-14)
  
  I'm writing a simple chess program from scratch on a hobbyist basis. I think there is something fundamental I'm overlooking or don't understand.
  
  I read the following <http://chessprogramming.wikispaces.com/Alpha-Beta>, as well as other articles, e.g. the Wikipedia one. I've also implemented alpha-beta blindly before just by following pseudo-code. I believe I understand how alpha-beta can guarantee no unsafe pruning takes place on a complete search tree, i.e. if you have the whole search tree, and there are no unexplored nodes beyond the horizon.
  
  What I don't understand is how alpha-beta can guarantee no unsafe pruning takes place on an *incomplete search tree* which does contain such unexplored nodes beyond the horizon, which chess always results in, unless evaluating endgames with a small enough tree.
  
  Consider the following explanation from: <http://chessprogramming.wikispaces.com/Alpha-Beta>
  
  > Say it is White's turn to move, and we are searching to a depth of 2
  > (that is, we are consider all of White's moves, and all of Black's
  > responses to each of those moves.) First we pick one of White's
  > possible moves - let's call this Possible Move #1. We consider this
  > move and every possible response to this move by black. After this
  > analysis, we determine that the result of making Possible Move #1 is
  > an even position. Then, we move on and consider another of White's
  > possible moves (Possible Move #2.) When we consider the first possible
  > counter-move by black, we discover that playing this results in black
  > winning a Rook! In this situation, we can safely ignore all of Black's
  > other possible responses to Possible Move #2 because we already know
  > that Possible Move #1 is better.
  
  This seems to be false to me, exploring further nodes on the branch of "Possible Move" #2, e.g. a couple more ply, could result in black being guaranteed checkmate?
  
  Hence pruning away this as a possible move is not safe.
  
  What am I missing?
  
  I know this ties in with the horizon effect and quiescence search, however I don't understand how alpha-beta alone, when used in this way on an incomplete search tree can be considered "safe". But I'm sure there is something I'm overlooking and it would be great with some pointers.
  
  **Tags:** engines, chess-algorithms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-03-15. Score: 2 | Accepted answer
  
  As far as I can tell, you are crystal clear conceptually, and you aren't actually missing anything. I think the source of any apparent conflict between your understanding and the quoted passage is that you may be reading the passage to be claiming more than it really is. Here it is again, with some added emphasis:
  
  > Say it is White's turn to move, and **we are searching to a depth of 2** (that is, we are consider all of White's moves, and all of Black's responses to each of those moves.) First we pick one of White's possible moves - let's call this Possible Move #1. We consider this move and every possible response to this move by black. After this analysis, we determine that the result of making Possible Move #1 is an even position. Then, we move on and consider another of White's possible moves (Possible Move #2.) When we consider the first possible counter-move by black, we discover that playing this results in black winning a Rook! In this situation, **we can safely ignore all of Black's other possible responses to Possible Move #2 because we already know that Possible Move #1 is better**.
  
  I think that the only point being made here is that in this particular situation, "we already know that Possible Move #1 is better" *as far as our limited depth search is concerned*. That is, we have fixed this depth of 2 ply for our search in advance, that is as far as our knowledge is going to go, and the information discovered in the scenario does conclusively show that *within the scope of the next 2 plies* Possible Move #1 is better than Possible Move #2.
  
  Your worry that something crucial might be being missed beyond that limit is absolutely correct, of course, and is why ideally such an algorithm would search all the way to the end of the entire chess game tree. That would be the only way to know that we have no "unsafe pruning," or in other words that we are playing optimally. But going that far isn't feasible (except for e.g. certain endgame positions, as you note, or say positions that are close to a forced conclusion of a game), so in whatever reasonable, finite amount of time an engine will have to search, it will only make it to some particular depth N that is insufficient for complete certainty. The point being made in the above passage isn't that we know Possible Move #1 is *truly* better than Possible Move #2 (i.e. with respect to the entire game tree), but only that we know it is definitely better with respect to the fixed depth N we actually get to search. But that's OK, as that's all we could possibly be sure of, which is exactly your point.
  
  
  ---
  
  