From 91075742062b400f966395d7ff08d1bc32b13ccd Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Fri, 14 Jan 2022 17:13:22 +0100 Subject: [PATCH] 4gewinnt: calcScore pointsForFirstRow added --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 368dd08..f1c2619 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -156,6 +156,10 @@ public class Logic { } } } + if(playfield[5][0] != 0 && playfield[5][1] != 0 && playfield[5][2] != 0 + && playfield[5][3] != 0 && playfield[5][4] != 0 && playfield[5][5] != 0) { + score += 60; + } return score; } } diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 97aeda7..52ed2bc 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -125,9 +125,16 @@ class LogicTest { {0, 0, 1, 2, 0, 0}, {0, 0, 1, 2, 0, 0}, {0, 0, 1, 1, 2, 0}}; + int[][] playfield2 = {{0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0}, + {1, 1, 1, 2, 2, 2}}; return Stream.of( Arguments.of("emptyField", new int[6][6], 1, 1000), - Arguments.of("9 chips played", playfield1, 1, 1090) + Arguments.of("9 chips played", playfield1, 1, 1090), + Arguments.of("first row filled", playfield2, 1, 1120) ); }