Im doing a invencible tic tac toe, but my minimax doesnt work -_- please I need to know where is my mistake, this is urgent

I want the cross to win, cross will always play firstCode:#include <algorithm> #include <cstdlib> using namespace std; int cross; int board[3][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; int winner( ) { for (int player = -1; player <= 1; player += 2) { for (int i = 0; i < 3; ++i) { if (board[i][0] == player && board[i][1] == player && board[i][2] == player) { return player; } if (board[0][i] == player && board[1][i] == player && board[2][i] == player) { return player; } } if (board[1][1] == player) { if (board[0][0] == player && board[2][2] == player) { return player; } if (board[2][0] == player && board[0][2] == player) { return player; } } } return 0; } int best_move( ) { if (cross > 0) { int maxv = -2; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (board[i][j] == 0) { board[i][j] = cross; cross = -cross; maxv = max(maxv, best_move( )); if (maxv == 1) { return 1; } cross = -cross; board[i][j] = 0; } } } return max(winner( ), maxv); } else { int minv = 2; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (board[i][j] == 0) { board[i][j] = cross; cross = -cross; minv = min(minv, best_move( )); if (minv == -1) { return -1; } cross = -cross; board[i][j] = 0; } } } return min(winner( ), minv); } } int main( ) { cross = 1; int best_place; int max_result = -2; cross = 1; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (board[i][j] == 0) { board[i][j] = cross; cross = -cross; int res = max(winner( ), best_move( )); if (max_result < res) { best_place = (i * 3) + j; max_result = res; } if (max_result == 1) { return best_place; } cross = -cross; board[i][j] = 0; } } } return best_place; }

cross = 1, round = -1, withouth mark/tie = 0

please