title: Determine best move in tic tac toe
body: <p>i want to code a recursive function to determine the best move in a given tic - tac - toe game</p>
  
  <pre><code>int nextMove(struct Game g, enum Symbol player) {
  if (game_over(g) != 0) {
  return -1;
  }
  int i, j;
  int score, end;
  for(i = 0; i &lt; 3; i += 1) {
      for (j = 0; j &lt; 3; j += 1) {
          if(g.board.fields[i][j] == 0) {
              g.board.fields[i][j] = player;
              score = nextMove(g, -player);
          }
      }
  }
  end = game_over(g)
  }
  </code></pre>
  
  <p>My game_over function :</p>
  
  <pre><code>enum Symbol game_over(struct Game g)
  {
  int x, y = x = 0;
  int full = 0;
  
  for (y = 0; y &lt; SIZE_Y_AXIS; y += 1)
  {
      for (x = 0; x &lt; SIZE_X_AXIS; x += 1)
      {
          if (g.board.fields[x][y] == NONE)
              full++;
          else if (x &lt; SIZE_X_AXIS - 2 &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x+1][y] &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x+2][y])
              return g.board.fields[x][y];
          else if (y &lt; SIZE_Y_AXIS - 2 &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x][y+1] &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x][y+2])
              return g.board.fields[x][y];
          else if (x &lt; SIZE_X_AXIS - 2 &amp;&amp; y &lt; SIZE_Y_AXIS - 2 &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x+1][y+1] &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x+2][y+2])
              return g.board.fields[x][y];
          else if (x &gt;= 2 &amp;&amp; y &lt; SIZE_Y_AXIS - 2 &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x-1][y+1] &amp;&amp;
                   g.board.fields[x][y] == g.board.fields[x-2][y+2])
              return g.board.fields[x][y];
      }
  }
  if (full == 0)
      return FULL;
  return NONE;
  }
  </code></pre>
  
  <p>I think the leaf production works fine, but i don't know how to determine which leaf (or which move) is the best one? Any suggestions by now?</p>
  
  <p>Thanks</p>