From 08bd0b7fad3840ac3d3ea52cec1ae871b060e3f7 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Fri, 14 Jan 2022 18:25:07 +0100 Subject: [PATCH] 4gewinnt: calcScore bonusForFullField --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 3 +++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 9 ++++++++- 2 files changed, 11 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 6e082ba..e79bcf8 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -170,6 +170,9 @@ public class Logic { } } } + if(score == 2080) { + score += 500; + } 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 c6efc6d..0531164 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -149,13 +149,20 @@ class LogicTest { {2, 0, 2, 0, 0, 0}, {1, 0, 2, 0, 0, 0}, {1, 0, 1, 0, 0, 0}}; + int[][] playfield6 = {{1, 1, 1, 1, 2, 2}, + {2, 1, 1, 1, 1, 2}, + {2, 1, 1, 2, 1, 2}, + {2, 1, 1, 2, 1, 2}, + {2, 1, 2, 2, 1, 2}, + {2, 1, 2, 2, 1, 2}}; return Stream.of( Arguments.of("emptyField", new int[6][6], 1, 1000), Arguments.of("9 chips played", playfield1, 1, 1090), Arguments.of("first row filled", playfield2, 1, 1120), Arguments.of("2 rows filled", playfield3, 1, 1240), Arguments.of("first column filled", playfield4, 1, 1120), - Arguments.of("2 column filled", playfield5, 1, 1240) + Arguments.of("2 column filled", playfield5, 1, 1240), + Arguments.of("fullyFilled", playfield6, 1, 2580) ); }