Skip to content
Snippets Groups Projects
Commit b13fc289 authored by Jan's avatar Jan
Browse files

updated game logic

parent 9c1297e8
No related branches found
No related tags found
1 merge request!1Verision 1.0 finished
...@@ -50,8 +50,12 @@ public class TicTacToe extends Application { ...@@ -50,8 +50,12 @@ public class TicTacToe extends Application {
} else { } else {
// TODO Gegner ist am Zug // 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 // TODO Spielablauf
......
...@@ -14,13 +14,14 @@ public interface Actor { ...@@ -14,13 +14,14 @@ public interface Actor {
} }
// Methode für Gegner (Zufallsgenerator) // Methode für Gegner (Zufallsgenerator)
default boolean makeMove(Board board) { default int[] makeMove(Board board) {
Random random = new Random(); Random random = new Random();
int x, y; int x, y;
do { do {
x = random.nextInt(3); x = random.nextInt(3);
y = random.nextInt(3); y = random.nextInt(3);
} while (!board.placeToken(x, y, symbol)); } while (!board.placeToken(x, y, symbol));
return true; int[] coordinates = {x, y};
return coordinates;
} }
} }
package logic; package logic;
import java.util.Random;
public class Enemy implements Actor { public class Enemy implements Actor {
public char symbol; public char symbol;
public Enemy() { 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