From edfb4ffe51beca2e24818dcd812fdddb1050c6a8 Mon Sep 17 00:00:00 2001 From: Stef Date: Wed, 29 Oct 2025 20:03:07 +0100 Subject: [PATCH] Changed checkForEarlyDraw so it doesn't need a game as input. --- .../main/java/org/toop/game/tictactoe/TicTacToe.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/game/src/main/java/org/toop/game/tictactoe/TicTacToe.java b/game/src/main/java/org/toop/game/tictactoe/TicTacToe.java index 19d48a3..3d8f5f7 100644 --- a/game/src/main/java/org/toop/game/tictactoe/TicTacToe.java +++ b/game/src/main/java/org/toop/game/tictactoe/TicTacToe.java @@ -49,7 +49,7 @@ public final class TicTacToe extends TurnBasedGame { nextTurn(); if (movesLeft <= 2) { - if (movesLeft <= 0 || checkForEarlyDraw(this)) { + if (movesLeft <= 0 || checkForEarlyDraw()) { return GameState.DRAW; } } @@ -85,11 +85,11 @@ public final class TicTacToe extends TurnBasedGame { return this.getBoard()[2] != EMPTY && this.getBoard()[2] == this.getBoard()[4] && this.getBoard()[2] == this.getBoard()[6]; } - private boolean checkForEarlyDraw(TicTacToe game) { - for (final Move move : game.getLegalMoves()) { - final TicTacToe copy = new TicTacToe(game); + private boolean checkForEarlyDraw() { + for (final Move move : this.getLegalMoves()) { + final TicTacToe copy = new TicTacToe(this); - if (copy.play(move) == GameState.WIN || !checkForEarlyDraw(copy)) { + if (copy.play(move) == GameState.WIN || !copy.checkForEarlyDraw()) { return false; } }