Search in sources :

Example 41 with LockedReachable

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);
    }
}
Also used : Action(common.datastore.action.Action) Field(core.field.Field) LockedCandidate(core.action.candidate.LockedCandidate) Piece(core.mino.Piece) LockedReachable(core.action.reachable.LockedReachable) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest)

Example 42 with LockedReachable

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);
}
Also used : Field(core.field.Field) LockedCandidate(core.action.candidate.LockedCandidate) Action(common.datastore.action.Action) Piece(core.mino.Piece) LockedReachable(core.action.reachable.LockedReachable) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

LockedReachable (core.action.reachable.LockedReachable)42 Field (core.field.Field)41 LongTest (module.LongTest)38 Test (org.junit.jupiter.api.Test)35 Piece (core.mino.Piece)34 Action (common.datastore.action.Action)31 LockedCandidate (core.action.candidate.LockedCandidate)30 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 MinoRotation (core.srs.MinoRotation)18 MinoFactory (core.mino.MinoFactory)17 MinoShifter (core.mino.MinoShifter)17 ColumnField (core.column_field.ColumnField)16 InOutPairField (searcher.pack.InOutPairField)16 Randoms (lib.Randoms)13 List (java.util.List)11 FieldFactory (core.field.FieldFactory)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 PermutationIterable (common.iterable.PermutationIterable)8 OperationTransform (common.parser.OperationTransform)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8