title: sorting move before alpha beta pruning - tic tac toe - python
body: <p>I have the negascout or principal variation search algorithms working fine to solve tic tac toe.  I have read somewhere that for these algorithms to be most efficient it is important to sort the moves such that the search starts with what is likely going to be the best move.</p>
  
  <p>Assume the heuristic that in tic tac toe, the center square is better than a corner square, which is better than a side square. </p>
  
  <p>I represent a square in tic tac toe by an integer between 1 and 9, as ordered on a numerical keypad.  In Python3, I am currently doing:</p>
  
  <pre><code>def sort_candidate_move(candidate_move):
      # center &gt; corner &gt; side
      move_dict = {1: 'b', 2: 'c', 3: 'b', 4: 'c', 5: 'a', 6: 'c', 7: 'b', 8: 'c', 9: 'b'}
      to_sort = [(move_dict[move], move) for move in candidate_move]
      to_sort.sort()
      return [tup[1] for tup in to_sort]
  </code></pre>
  
  <p>where candidate_move is the list of candidate moves, for example:</p>
  
  <pre><code>candidate_move = [2, 5, 9]
  </code></pre>
  
  <p>The code returns:</p>
  
  <pre><code>[5, 9, 2]
  </code></pre>
  
  <p>It seems that ordering moves that way does not give any benefit in terms of  computing time to solve tic tac toe.</p>
  
  <p>Is there a more efficient way (in terms of computation speed) to code the function sort_candidate_move()?</p>