I am making a Tic Tac Toe game, now I have the easy, and medium done, all I need is the hard, here is my code at the moment code: | public static void hard(String phrase) {
int winner = 0;
board[1][1] = " X ";
int c = 2;
phrase = getPhrase();
while (winner == 0) {
if (c % 2 == 0) {
rowColumn(phrase, "1", 2);
} else {
System.out.println("hello");
if (board[0][0].equals(" - ")) {
board[0][0] = " X ";
} else if (!board[0][0].equals(" - ") && board[0][2].equals(" - ")) {
board[0][2] = " X ";
} else if (!board[0][0].equals(" - ") && !board[0][2].equals(" - ") && board[2][0].equals(" - ")) {
board[2][0] = " X ";
} else if (!board[0][0].equals(" - ") && !board[0][2].equals(" - ") && !board[2][0].equals(" - ") && board[2][2].equals(" - ")) {
board[2][2] = " X ";
}
}
phrase = getPhrase();
winner = determineWin();
c++;
}
if (winner == 2) {
System.out.println("you win");
} else if (winner == 1) {
System.out.println("cpu wins");
}
} | Now I dont want help with coding or anything, but the code above will put an X according to which corners are open, and I wouldnt know which part of the if statement I would need to put another if statment to check if there is a spot open for a win, like for example if you have(below), which part of the if statement would you make the computer put an x where it
would win
Quote: X - X
- X O
- - O |