From 7e3f13491d5f1278212da16c5ea8511506fa413f Mon Sep 17 00:00:00 2001 From: ramollia <@> Date: Sun, 5 Oct 2025 17:52:29 +0200 Subject: [PATCH] fix: some things --- .../app/layer/layers/game/TicTacToeLayer.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/toop/app/layer/layers/game/TicTacToeLayer.java b/app/src/main/java/org/toop/app/layer/layers/game/TicTacToeLayer.java index 1750b3f..aadc783 100644 --- a/app/src/main/java/org/toop/app/layer/layers/game/TicTacToeLayer.java +++ b/app/src/main/java/org/toop/app/layer/layers/game/TicTacToeLayer.java @@ -32,7 +32,17 @@ public final class TicTacToeLayer extends Layer { canvas = new TicTacToeCanvas(Color.WHITE, (App.getHeight() / 100) * 75, (App.getHeight() / 100) * 75, (cell) -> { 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) { return; } @@ -45,6 +55,8 @@ public final class TicTacToeLayer extends Layer { if (information.isConnectionLocal()) { new Thread(this::localGameThread).start(); + } else { + new Thread(this::serverGameThread).start(); } reload(); @@ -91,8 +103,6 @@ public final class TicTacToeLayer extends Layer { while (running) { final int currentPlayer = ticTacToe.getCurrentTurn(); - System.out.println("test"); - Game.Move move = null; if (information.isPlayerHuman()[currentPlayer]) { @@ -102,7 +112,7 @@ public final class TicTacToeLayer extends Layer { return; } } else { - move = ticTacToeAI.findBestMove(ticTacToe, compurterDifficultyToDepth(9, information.computerDifficulty()[currentPlayer])); + move = ticTacToeAI.findBestMove(ticTacToe, compurterDifficultyToDepth(5, information.computerDifficulty()[currentPlayer])); } 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(); + } + } } \ No newline at end of file