use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckmateUsingHoldTest method testLong9.
@Test
void testLong9() throws Exception {
List<Pair<List<Piece>, Integer>> testCases = new ArrayList<Pair<List<Piece>, Integer>>() {
{
add(new Pair<>(Arrays.asList(I, S, Z, T, J, I, S, Z, S, Z), 29));
add(new Pair<>(Arrays.asList(T, S, L, I, Z, J, L, O, O, S), 49));
add(new Pair<>(Arrays.asList(L, Z, S, J, Z, Z, Z, I, T, T), 40));
// PCF: 106
add(new Pair<>(Arrays.asList(T, T, S, S, Z, Z, L, L, J, J), 107));
add(new Pair<>(Arrays.asList(O, S, O, S, Z, L, Z, L, I, I), 3));
// PCF: 112
add(new Pair<>(Arrays.asList(J, I, T, O, L, S, I, T, Z, O), 113));
add(new Pair<>(Arrays.asList(S, T, J, L, O, O, T, S, L, L), 82));
add(new Pair<>(Arrays.asList(S, T, J, L, O, O, T, S, L), 36));
// PCF: 16
add(new Pair<>(Arrays.asList(Z, S, T, I, O, J, L, Z, S), 17));
add(new Pair<>(Arrays.asList(S, T, J, L, O, O, T, S, L), 36));
}
};
// Field
String marks = "" + "__________" + "X_________" + "X_________" + "XX________" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 4;
int maxDepth = 9;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
for (Pair<List<Piece>, Integer> testCase : testCases) {
// Set test case
List<Piece> pieces = testCase.getKey();
int expectedCount = testCase.getValue();
// Execute
List<Result> results = checkmate.search(field, pieces, candidate, maxClearLine, maxDepth);
assertThat(results).as(pieces.toString()).hasSize(expectedCount);
// Check result
for (Result result : results) assertResult(result, field, maxClearLine, reachable, pieces);
}
}
use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckmateUsingHoldTest method testCaseList.
@ParameterizedTest
@ArgumentsSource(TestCase.class)
@LongTest
void testCaseList(Pieces pieces, int expectedCount) throws Exception {
// Field
int maxClearLine = 4;
int maxDepth = 10;
Field field = FieldFactory.createField(maxClearLine);
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
// Set test case
List<Piece> piecesList = pieces.getPieces();
// Execute
List<Result> results = checkmate.search(field, piecesList, candidate, maxClearLine, maxDepth);
assertThat(results).as(piecesList.toString()).hasSize(expectedCount);
// Check result
for (Result result : results) assertResult(result, field, maxClearLine, reachable, piecesList);
}
Aggregations