Question: public int [ ] minimax ( char player ) { int [ ] bestMove = { - 1 , - 1 } ; int bestScore

public int[] minimax(char player){
int[] bestMove ={-1,-1};
int bestScore =(player =='O')? Integer.MIN_VALUE : Integer.MAX_VALUE;
for (int i =0; i <3; i++){
for (int j =0; j <3; j++){
if (a[i][j].value ==''){
a[i][j].value = player;
int score = minimaxScore(false);
a[i][j].value ='';
if ((player =='O' && score >= bestScore)||(player =='X' && score <= bestScore)){
bestScore = score;
bestMove[0]= i;
bestMove[1]= j;
}
}
}
}
return bestMove;
} in this code it doesn't give me the shortest path for win , Modify it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!