From 8961708346a3b876d8262ccdba13207056991e36 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Wed, 2 Feb 2022 13:35:59 +0100 Subject: [PATCH] 4gewinnt: added getFreePlace method --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index c557bbc..3030511 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -58,6 +58,10 @@ public class Logic { return this.player2Score; } + public int getFreePlace(int column) { + return this.getBoardSize(); + } + public int playChip(int column) { //add board update diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index d423d58..b6e55bd 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -187,6 +187,11 @@ class LogicTest { assertEquals(10, testObj.getPlayer1Score()); } + @Test + void getFreePlaceTest() { + assertEquals(testObj.getBoardSize(), testObj.getFreePlace(0)); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},