Skip to content
Snippets Groups Projects
Commit aa03e77a authored by Jan's avatar Jan Committed by Nick
Browse files

updated game logic

parent ace7621f
No related branches found
No related tags found
1 merge request!2Fehler fix
......@@ -50,8 +50,12 @@ public class TicTacToe extends Application {
} else {
// TODO Gegner ist am Zug
int[] coordinates = enemy.makeMove(board);
// DEBUG
System.out.println("Enemy: " + coordinates[0] + ", " + coordinates[1]);
sceneController.aiTurn(coordinates[0], coordinates[1]);
}
// TODO Spielablauf
......
......@@ -14,13 +14,14 @@ public interface Actor {
}
// Methode für Gegner (Zufallsgenerator)
default boolean makeMove(Board board) {
default int[] makeMove(Board board) {
Random random = new Random();
int x, y;
do {
x = random.nextInt(3);
y = random.nextInt(3);
} while (!board.placeToken(x, y, symbol));
return true;
int[] coordinates = {x, y};
return coordinates;
}
}
package logic;
import java.util.Random;
public class Enemy implements Actor {
public char symbol;
public Enemy() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment