Answers.Body: <p>My usual reference is <a href="https://chessprogramming.wikispaces.com/Alpha-Beta#Implementation-Negamax%20Framework" rel="nofollow noreferrer">https://chessprogramming.wikispaces.com/Alpha-Beta#Implementation-Negamax%20Framework</a>, which I believe is correct.</p>
  
  <p>In your lecture slide, if <code>score &gt; beta</code> ==> <code>alpha = score</code> ==> return alpha which is greater than beta. Thus, the claim looks incorrect to me.</p>
  
  <p>You don't need to prove "<em>increasing function of alpha</em>" because any score less than alpha is a bad move for you, so you would ignore it.</p>
  
  <p>Aspiration window width is a parameter and there is no definitive answer. You don't want it too big, or too small. You'll need to run tests...</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-28T19:38:54.087Z
Answers.Text: Thanks a bunch! I 've seen this before. There are many variants out there and I think I will go for this one.
Answers.UserDisplayName: plus1
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-28T13:31:12.257Z
Answers.LastActivityDate: 2018-03-28T13:36:54.170Z
Answers.LastEditDate: 2018-03-28T13:36:54.170Z
Answers.UserDisplayName: SmallChess
Body: <p>I am coding up a chess engine and using the alpha-beta algorithm for tree scanning. I ended up doing what they posted <a href="https://www.ics.uci.edu/~eppstein/180a/990202b.html" rel="nofollow noreferrer">here</a>:</p>
  
  <pre><code>int alphabeta(int depth, int alpha, int beta)
  {
      move bestmove;
      if (game over or depth &lt;= 0) return winning score or eval();
      for (each possible move m) {
          make move m;
          score = -alphabeta(depth - 1, -beta, -alpha)
          if (score &gt;= alpha) { alpha = score; bestmove = m; }
          unmake move m;
          if (alpha &gt;= beta) break;
      }
      return alpha;
  } 
  </code></pre>
  
  <p>It is stated that "The code above always returns alpha, beta, or a number between alpha and beta." In my calcs this is not true and I need it in order to implement aspiration search. I have seen many variants of the algorithm and tried a few but sometimes the return value falls outside the desired interval [alpha, beta]. </p>
  
  <ol>
  <li><p>Can anyone post C++ or pseudo-code of alpha-beta with that property? </p></li>
  <li><p>Is it possible to prove that ? </p></li>
  <li><p>Finally, it seems intuitive that the return value is an increasing function of alpha keeping beta fixed and similarly for beta. Is it true and is it provable? In my calcs this is not the case.</p></li>
  <li><p>How big must be the window of aspiration search in order to ensure we have not pruned out the principal variation? If the return value falls between  alpha and beta will that suffice?</p></li>
  </ol>
  
Tags: <opening><engines><software><strategy>
Title: alpha-beta algorithm returns a value between alpha and beta inclusive?
ThreadText: # alpha-beta algorithm returns a value between alpha and beta inclusive?
  
  (Asked by: username_0 on 2018-03-28)
  
  I am coding up a chess engine and using the alpha-beta algorithm for tree scanning. I ended up doing what they posted here:
  int alphabeta(int depth, int alpha, int beta)
  {
      move bestmove;
      if (game over or depth <= 0) return winning score or eval();
      for (each possible move m) {
          make move m;
          score = -alphabeta(depth - 1, -beta, -alpha)
          if (score >= alpha) { alpha = score; bestmove = m; }
          unmake move m;
          if (alpha >= beta) break;
      }
      return alpha;
  } 
  
  It is stated that "The code above always returns alpha, beta, or a number between alpha and beta." In my calcs this is not true and I need it in order to implement aspiration search. I have seen many variants of the algorithm and tried a few but sometimes the return value falls outside the desired interval [alpha, beta]. 
  
  Can anyone post C++ or pseudo-code of alpha-beta with that property? 
  Is it possible to prove that ? 
  Finally, it seems intuitive that the return value is an increasing function of alpha keeping beta fixed and similarly for beta. Is it true and is it provable? In my calcs this is not the case.
  How big must be the window of aspiration search in order to ensure we have not pruned out the principal variation? If the return value falls between  alpha and beta will that suffice?
  
  **Tags:** opening, engines, software, strategy
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-28. Score: 2 | Accepted answer
  
  My usual reference is <https://chessprogramming.wikispaces.com/Alpha-Beta#Implementation-Negamax%20Framework>, which I believe is correct.
  
  In your lecture slide, if `score > beta` ==> `alpha = score` ==> return alpha which is greater than beta. Thus, the claim looks incorrect to me.
  
  You don't need to prove "*increasing function of alpha*" because any score less than alpha is a bad move for you, so you would ignore it.
  
  Aspiration window width is a parameter and there is no definitive answer. You don't want it too big, or too small. You'll need to run tests...
  
  > **Comments:**
  > **username_0**: Thanks a bunch! I 've seen this before. There are many variants out there and I think I will go for this one.  
  
  ---
  
  