mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
fix: some things
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user