I am trying to develop an optimal evaluation function to use in minimax/alpha-beta algorithm for developing tic-tac-toe AI. I am counting number of circles/crosses in a row/column/diagonal with empty space behind it (with three-in-a-row, there is no empty space). Based on number of symbols in such line, I multiply the separate scores with \$10^{\text{counter} - 1}\$, which results in \$1,10 \text{ or } 100\$ points. I am sure much can be improved, because optimal solution is rarely found and I am having problems using this function in alphabeta algorithmMy question is - How can this function be improved? Small pieces of code and suggestions appreciated.My code:private int h(int[][] field, int depth, int player) //final score of the node        {            if (win(field, 1)) //if human won                return -1000; //very bad for MAX=computer            if (win(field, 0)) //if computer won                return 1000;            int heuristics = individualScore(field, 0) - individualScore(field, 1);            return heuristics;        }private int individualScore(int[][] field, int player)        {            int sum = 0;            int otherPlayer = -1;            if (player == 0) //if computer is the current player                otherPlayer = 1; //other player is human            else                otherPlayer = 0;//Vice versa            for (int i = 0; i < 3; i++) // rows            {                int counter = 0;                bool rowAvailable = true;                for (int l = 0; l < 3; l++)                {                    if (field[i][l] == player)                        counter++;                    if (field[i][l] == otherPlayer)                    {                        rowAvailable = false;                        break;                    }                }                if (rowAvailable && counter > 0)                    sum += (int)Math.Pow(10, counter - 1);            }            for (int i = 0; i < 3; i++) // columns            {                int counter = 0;                bool columnAvailable = true;                for (int k = 0; k < 3; k++)                {                    if (field[k][i] == player)                        counter++;                    if (field[k][i] == otherPlayer)                    {                        columnAvailable = false;                        break;                    }                }                if (columnAvailable && counter > 0)                    sum += (int)Math.Pow(10, counter - 1);            }            int counterD = 0;            bool diagonalAvailable = true;            for (int i = 0; i < 3; i++) //diagonals            {                if (field[i][i] == player)                    counterD++;                if (field[i][i] == otherPlayer)                {                    diagonalAvailable = false;                    break;                }            }            if (diagonalAvailable && counterD > 0)                sum += (int)Math.Pow(10, counterD - 1);            counterD = 0;            diagonalAvailable = true;            int j = 0;            for (int i = 2; i >= 0; i--)            {                if (field[i][j] == player)                    counterD++;                if (field[i][j] == otherPlayer)                {                    diagonalAvailable = false;                    break;                }            }            if (diagonalAvailable && counterD > 0)                sum += (int)Math.Pow(10, counterD - 1);            return sum;        }
Trying to develop evaluation function for minimax/alphabeta algorithm
c#;algorithm