title: Minimax with Alpha-beta pruning, getting the result
body: <p>I have followed the pseducode on the wikipedia article, and I think I got it working. However, it returns the score, and that doesn't exactly help when I want to know what move I want to make. </p>
  
  <p>I tried what I think would be a way to get the best move, but I don't think it is working as when I actually try to play against it (chess), the AI makes somewhat retarded moves with a depth level of 3. </p>
  
  <p>Here is my function: </p>
  
  <pre><code>public static function alphaBeta(node, depth, alph, beta, team, tellTheMove:Boolean = false):* {
          var pointer:ChessMove;
          if (depth == 0) {
              return scoreOf(node);
          }
          var childrenOf:Vector.&lt;ChessMove &gt;  = returnPossibleMoves(node,team);
          if (childrenOf.length == 0) {
              return scoreOf(node);
          }
          if (team == 0) {
              for (var i in childrenOf) {
                  var that:Number = alphaBeta(childrenOf[i],depth - 1,alph,beta,1);
                  if(tellTheMove){
                  }
                  if (that &gt; alph) {
                      alph = that;
                      if(tellTheMove){
                          pointer = childrenOf[i];
                      }
                  }
                  if (beta &lt;= alph) {
                      break;
                  }
              }
              if(tellTheMove){
                  return pointer; //Returns the move that's score last exceeded alpha.
              }
              return alph;
          } else {
              for (var j in childrenOf) {
                  var that2:Number = alphaBeta(childrenOf[j],depth - 1,alph,beta,0);
                  if (that2 &lt; beta) {
                      beta = that2;
                  }
                  if (beta &lt;= alph) {
                      break;
                  }
              }
              return beta;
          }
      }
  </code></pre>