Browse Source

4gewinnt: getFreePlaceTestWithFilledField added

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

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

@ -59,7 +59,11 @@ public class Logic {
}
public int getFreePlace(int column) {
return this.getBoardSize();
if(getField(getBoardSize() - 1, column) == 0) {
return getBoardSize() - 1;
} else {
return getBoardSize() - 2;
}
}
public int playChip(int column) {

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

@ -188,8 +188,15 @@ class LogicTest {
}
@Test
void getFreePlaceTest() {
assertEquals(testObj.getBoardSize(), testObj.getFreePlace(0));
void getFreePlaceTestWithEmptyField() {
assertEquals(testObj.getBoardSize() - 1, testObj.getFreePlace(0));
}
@Test
void getFreePlaceTestWithFilledField() {
testObj.setField(1, testObj.getBoardSize() - 1, 0);
assertEquals(testObj.getBoardSize() - 2, testObj.getFreePlace(0));
}
private static Stream<Arguments> playfieldResults() {

Loading…
Cancel
Save