fix: some things

This commit is contained in:
ramollia
2025-10-05 17:52:29 +02:00
parent b5ac747f77
commit 7e3f13491d

View File

@@ -32,7 +32,17 @@ public final class TicTacToeLayer extends Layer {
canvas = new TicTacToeCanvas(Color.WHITE, (App.getHeight() / 100) * 75, (App.getHeight() / 100) * 75, (cell) -> { canvas = new TicTacToeCanvas(Color.WHITE, (App.getHeight() / 100) * 75, (App.getHeight() / 100) * 75, (cell) -> {
try { try {
playerMoveQueue.put(new Game.Move(cell, 'X')); if (information.isConnectionLocal()) {
if (ticTacToe.getCurrentTurn() == 0) {
playerMoveQueue.put(new Game.Move(cell, 'X'));
} else {
playerMoveQueue.put(new Game.Move(cell, 'O'));
}
} else {
if (ticTacToe.getCurrentTurn() == 0) {
// Todo: identify if we are x or o and put in queue
}
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
return; return;
} }
@@ -45,6 +55,8 @@ public final class TicTacToeLayer extends Layer {
if (information.isConnectionLocal()) { if (information.isConnectionLocal()) {
new Thread(this::localGameThread).start(); new Thread(this::localGameThread).start();
} else {
new Thread(this::serverGameThread).start();
} }
reload(); reload();
@@ -91,8 +103,6 @@ public final class TicTacToeLayer extends Layer {
while (running) { while (running) {
final int currentPlayer = ticTacToe.getCurrentTurn(); final int currentPlayer = ticTacToe.getCurrentTurn();
System.out.println("test");
Game.Move move = null; Game.Move move = null;
if (information.isPlayerHuman()[currentPlayer]) { if (information.isPlayerHuman()[currentPlayer]) {
@@ -102,7 +112,7 @@ public final class TicTacToeLayer extends Layer {
return; return;
} }
} else { } else {
move = ticTacToeAI.findBestMove(ticTacToe, compurterDifficultyToDepth(9, information.computerDifficulty()[currentPlayer])); move = ticTacToeAI.findBestMove(ticTacToe, compurterDifficultyToDepth(5, information.computerDifficulty()[currentPlayer]));
} }
assert move != null; assert move != null;
@@ -125,4 +135,12 @@ public final class TicTacToeLayer extends Layer {
} }
} }
} }
private void serverGameThread() {
boolean running = true;
while (running) {
final int currentPlayer = ticTacToe.getCurrentTurn();
}
}
} }