Search in sources :

Example 86 with MinoFactory

use of core.mino.MinoFactory in project solution-finder by knewjade.

the class LimitIterationCandidateTest method testSearch3When3Iteration.

@Test
void testSearch3When3Iteration() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    Candidate<Action> candidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 3);
    String marks = "" + "XXXX______" + "XX_XXXXX__" + "X___X_____" + "XX_X______";
    Field field = FieldFactory.createField(marks);
    Set<Action> actions = candidate.search(field, Piece.T, 4);
    assertThat(actions).hasSize(9).contains(MinimalAction.create(8, 0, Rotate.Spawn)).contains(MinimalAction.create(7, 0, Rotate.Spawn)).contains(MinimalAction.create(8, 1, Rotate.Reverse)).contains(MinimalAction.create(7, 1, Rotate.Reverse)).contains(MinimalAction.create(6, 1, Rotate.Reverse)).contains(MinimalAction.create(8, 3, Rotate.Reverse)).contains(MinimalAction.create(9, 1, Rotate.Left)).contains(MinimalAction.create(8, 1, Rotate.Left)).contains(MinimalAction.create(8, 1, Rotate.Right));
}
Also used : MinoRotation(core.srs.MinoRotation) Field(core.field.Field) MinimalAction(common.datastore.action.MinimalAction) Action(common.datastore.action.Action) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 87 with MinoFactory

use of core.mino.MinoFactory in project solution-finder by knewjade.

the class LimitIterationCandidateTest method testRandomLocked.

@Disabled
@Test
@LongTest
// TODO: mesure time, 移動回数をチェックしていないためテストに失敗することがある
void testRandomLocked() {
    Randoms randoms = new Randoms();
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    LimitIterationCandidate limitIterationCandidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 12);
    for (int count = 0; count < 10; count++) {
        int randomHeight = randoms.nextIntClosed(10, 12);
        int numOfMinos = randoms.nextIntClosed(4, randomHeight * 10 / 4 - 1);
        Field field = randoms.field(randomHeight, numOfMinos);
        int clearLine = field.clearLine();
        int height = randomHeight - clearLine;
        Piece piece = randoms.block();
        String description = FieldView.toString(field, height) + piece;
        Set<Action> actions1 = limitIterationCandidate.search(field, piece, height);
        LockedCandidate lockedCandidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, height);
        Set<Action> actions2 = lockedCandidate.search(field, piece, height);
        assertThat(actions2).as(description).isEqualTo(actions1);
    }
}
Also used : MinoRotation(core.srs.MinoRotation) Field(core.field.Field) Randoms(lib.Randoms) MinimalAction(common.datastore.action.MinimalAction) Action(common.datastore.action.Action) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest) LongTest(module.LongTest) Disabled(org.junit.jupiter.api.Disabled)

Example 88 with MinoFactory

use of core.mino.MinoFactory in project solution-finder by knewjade.

the class LockedNeighborCandidateTest method createLockedNeighborCandidate.

private LockedNeighborCandidate createLockedNeighborCandidate(Injector injector, int maxClearLine) {
    MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
    MinoShifter minoShifter = injector.getInstance(MinoShifter.class);
    MinoRotation minoRotation = injector.getInstance(MinoRotation.class);
    OriginalPieceFactory pieceFactory = new OriginalPieceFactory(maxClearLine + 3);
    return new LockedNeighborCandidate(minoFactory, minoShifter, minoRotation, pieceFactory);
}
Also used : MinoRotation(core.srs.MinoRotation) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) OriginalPieceFactory(core.neighbor.OriginalPieceFactory)

Example 89 with MinoFactory

use of core.mino.MinoFactory in project solution-finder by knewjade.

the class LockedNeighborCandidateTest method createLockedCandidate.

private LockedCandidate createLockedCandidate(Injector injector, int maxClearLine) {
    MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
    MinoShifter minoShifter = injector.getInstance(MinoShifter.class);
    MinoRotation minoRotation = injector.getInstance(MinoRotation.class);
    return new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
}
Also used : MinoRotation(core.srs.MinoRotation) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter)

Example 90 with MinoFactory

use of core.mino.MinoFactory in project solution-finder by knewjade.

the class LockedNeighborReachableTest method createLockedReachable.

private LockedReachable createLockedReachable(Injector injector, int maxClearLine) {
    MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
    MinoShifter minoShifter = injector.getInstance(MinoShifter.class);
    MinoRotation minoRotation = injector.getInstance(MinoRotation.class);
    return new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
}
Also used : MinoRotation(core.srs.MinoRotation) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter)

Aggregations

MinoFactory (core.mino.MinoFactory)113 Test (org.junit.jupiter.api.Test)70 MinoShifter (core.mino.MinoShifter)59 LongTest (module.LongTest)51 Field (core.field.Field)45 MinoRotation (core.srs.MinoRotation)40 ColorConverter (common.tetfu.common.ColorConverter)33 Piece (core.mino.Piece)28 Action (common.datastore.action.Action)22 ColumnField (core.column_field.ColumnField)22 Randoms (lib.Randoms)22 InOutPairField (searcher.pack.InOutPairField)21 LockedReachable (core.action.reachable.LockedReachable)17 PerfectValidator (searcher.common.validator.PerfectValidator)17 LockedCandidate (core.action.candidate.LockedCandidate)16 MinoOperationWithKey (common.datastore.MinoOperationWithKey)15 List (java.util.List)15 Collectors (java.util.stream.Collectors)15 PermutationIterable (common.iterable.PermutationIterable)12 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)12