title: How to set the score for a table in Tic Tac Toe?
body: <p>I have table and some functions like Generate_moves() etc. but for the minmax algorithm to work I need to set a score for tables to make the computer choose the best table. </p>
  
  <pre><code>        public int Score()
          {
              if (Turn == "X")
              {
                  if (gameWon("X")) return 100;
                  if (gameWon("O")) return -100;
                  if (gameDrawn()) return 0;
  
                  return n - canWin("X");
              }
  
              if (Turn == "O")
              {
                  if (gameWon("O")) return 100;
                  if (gameWon("X")) return -100;
                  if (gameDrawn()) return 0;
  
                  return n - canWin("O");
              }
  
              return -1;
          }
  </code></pre>
  
  <p>My <code>canWin(string)</code> returns a number that tells me how many Xs or Os i have in a straight line or column but I doubt it is a great why to set the score for a table.</p>
  
  <p>If I have the table:</p>
  
  <pre><code>X - X
  0 X 0
  - - 0
  </code></pre>
  
  <p>the score should be the same as</p>
  
  <pre><code>X - -
  0 - X
  0 0 X
  </code></pre>
  
  <p>and should be bigger than</p>
  
  <pre><code>X - X
  0 - -
  - 0 -
  </code></pre>
  
  <p>And I don't have any idea how to make the Score function tell me different scores. How can I implement the method Score to tell me this?</p>
  
  <p>Edit:</p>
  
  <p>if computer is first with X and me with O</p>
  
  <pre><code>X - -      X - -      X - -     X - -
  - - -   -&gt; 0 - -   -&gt; 0 X -  -&gt; 0 X -
  - - -      - - -      - - -     - - 0
  </code></pre>
  
  <p>now how can i make the computer choose that the next best option is </p>
  
  <pre><code>X - X
  0 X -
  - - 0
  </code></pre>