Browse Source

4gewinnt: calcScore pointsPerChip

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
6dd8f7a409
  1. 10
      src/main/java/de/tims/viergewinnt/ai/Logic.java
  2. 9
      src/test/java/de/tims/viergewinnt/ai/LogicTest.java

10
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -148,6 +148,14 @@ public class Logic {
}
public int calcScore(int[][] playfield, int player) {
return 0;
int score = 1000;
for(int i = 0; i < playfield.length; i++) {
for(int j = 0; j < playfield[i].length; j++) {
if(playfield[i][j] != 0) {
score += 10;
}
}
}
return score;
}
}

9
src/test/java/de/tims/viergewinnt/ai/LogicTest.java

@ -119,8 +119,15 @@ class LogicTest {
}
private static Stream<Arguments> playfieldForScore() {
int[][] playfield1 = {{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 1, 2, 0, 0},
{0, 0, 1, 2, 0, 0},
{0, 0, 1, 2, 0, 0},
{0, 0, 1, 1, 2, 0}};
return Stream.of(
Arguments.of("emptyField", new int[6][6], 1, 0)
Arguments.of("emptyField", new int[6][6], 1, 1000),
Arguments.of("9 chips played", playfield1, 1, 1090)
);
}

Loading…
Cancel
Save