Не работает алгоритм минимакса
Приветствуют. Пишу алгоритм Минимакс для игры 5 в ряд и столкнулся с проблемой, что мой алгоритм видимо не работает. Пробежавшись в отладчике, увидел что Evaluation не изменяется, не понимаю почему так и прошу помочь разобраться с проблемой. Логика программы заключается в том, что в функции getComputerPosition() ставится символ на пустое место, и далее вызывается сам минимаксный алгоритм, после чего высчитывается оценка и сохраняются координаты лучшего хода.
int miniMax(int board[N][N], int depth, bool isMaximising)
{
int Evaluation = 0;
int score = 0;
int computerChar = BLACK;
if (depth == 0)
{
return Evaluation;
}
if (isMaximising)
{
int Evaluation = std::numeric_limits<int>().min();
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
if (board[i][j] == BLANK)
{
board[i][j] = computerChar;
score = miniMax(board, depth - 1, userTurn);
board[i][j] = BLANK;
Evaluation = std::max(Evaluation, score);
}
}
}
}
else
{
int Evaluation = std::numeric_limits<int>().max();
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
if (board[i][j] == BLANK)
{
board[i][j] = -computerChar;
score = miniMax(board, depth - 1, aiTurn);
board[i][j] = BLANK;
Evaluation = std::min(Evaluation, score);
}
}
}
}
return Evaluation;
}
std::pair<int, int> getComputerPosition(int board[N][N])
{
int bestScore = 0;
int tempBestScore;
int bestXCoordinate;
int bestYCoordinate;
int tempBoard[N][N]; // board copy
int computerChar = BLACK;
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
tempBoard[i][j] = board[i][j];
}
}
for(int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
if (tempBoard[i][j] == BLANK)
{
tempBoard[i][j] = computerChar;
tempBestScore = miniMax(tempBoard, 5, userTurn);
tempBoard[i][j] = BLANK;
if (tempBestScore > bestScore)
{
bestScore = tempBestScore;
bestXCoordinate = i;
bestYCoordinate = j;
}
}
}
}
return std::make_pair(bestXCoordinate, bestYCoordinate);
}