|
@ -1,8 +1,11 @@ |
|
|
package de.tims.fleetstorm.ai; |
|
|
package de.tims.fleetstorm.ai; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertNotEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertNotEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
import de.tims.fleetstorm.matchfield.Coordinate; |
|
|
import de.tims.fleetstorm.matchfield.Coordinate; |
|
@ -31,13 +34,39 @@ class LogicTest { |
|
|
|
|
|
|
|
|
for (int x = 0; x < size; x++) { |
|
|
for (int x = 0; x < size; x++) { |
|
|
for (int y = 0; y < size; y++) { |
|
|
for (int y = 0; y < size; y++) { |
|
|
// matchfield.setState(x, y, Matchfield.SHOT); |
|
|
|
|
|
|
|
|
matchfield.setState(x, y, Coordinate.SHOT); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// matchfield.setState(0, 0, Matchfield.EMPTY); |
|
|
|
|
|
|
|
|
matchfield.setState(2, 2, Coordinate.EMPTY); |
|
|
|
|
|
|
|
|
Coordinate choosenField = logic.chooseField(matchfield); |
|
|
Coordinate choosenField = logic.chooseField(matchfield); |
|
|
int calcState = matchfield.getState(choosenField.getX(), choosenField.getY()); |
|
|
int calcState = matchfield.getState(choosenField.getX(), choosenField.getY()); |
|
|
assertNotEquals(calcState, Coordinate.SHOT); |
|
|
assertNotEquals(calcState, Coordinate.SHOT); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testGetEverySecondField() { |
|
|
|
|
|
Logic logic = new Logic(); |
|
|
|
|
|
Matchfield matchfield; |
|
|
|
|
|
int size = 4; |
|
|
|
|
|
matchfield = new Matchfield(size); |
|
|
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Coordinate> everySecondField = logic.getEverySecondField(matchfield); |
|
|
|
|
|
ArrayList<Coordinate> expectedResult = new ArrayList<Coordinate>(); |
|
|
|
|
|
|
|
|
|
|
|
expectedResult.add(new Coordinate(0, 0)); |
|
|
|
|
|
expectedResult.add(new Coordinate(0, 2)); |
|
|
|
|
|
expectedResult.add(new Coordinate(1, 1)); |
|
|
|
|
|
expectedResult.add(new Coordinate(1, 3)); |
|
|
|
|
|
expectedResult.add(new Coordinate(2, 0)); |
|
|
|
|
|
expectedResult.add(new Coordinate(2, 2)); |
|
|
|
|
|
expectedResult.add(new Coordinate(3, 1)); |
|
|
|
|
|
expectedResult.add(new Coordinate(3, 3)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < expectedResult.size(); i++) { |
|
|
|
|
|
assertEquals(everySecondField.get(i).getX(), expectedResult.get(i).getX()); |
|
|
|
|
|
assertEquals(everySecondField.get(i).getY(), expectedResult.get(i).getY()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |