fixed bug in AI

This commit is contained in:
MaurizioBruetsch 2017-10-21 12:07:07 +02:00
parent dd68bbf6c7
commit 101ef5bd89

View file

@ -36,12 +36,16 @@ public class MaurizioAI implements Player {
for(int i=0;i<Game.GAME_COLUMNS;i++){ for(int i=0;i<Game.GAME_COLUMNS;i++){
if(board[i][0] == 0){ if(board[i][0] == 0){
int[][] boardNew = makeMove(board, i, id); int[][] boardNew = makeMove(board, i, id);
boolean loser = false;
for(int j=0;j<Game.GAME_COLUMNS;j++){ for(int j=0;j<Game.GAME_COLUMNS;j++){
if(boardNew[j][0] == 0 && checkWin(boardNew, j, enemyID)){ if(boardNew[j][0] == 0 && checkWin(boardNew, j, enemyID)){
return j; // NOPE !!! loser = true;
break;
} }
} }
return i; if(!loser){
return i;
}
} }
} }
return moveRandom(board); return moveRandom(board);