Search in sources :

Example 36 with MinoRotation

use of core.srs.MinoRotation 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 37 with MinoRotation

use of core.srs.MinoRotation 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 38 with MinoRotation

use of core.srs.MinoRotation in project solution-finder by knewjade.

the class LockedCandidateTest method testSearch3.

@Test
void testSearch3() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, 4);
    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(11).contains(MinimalAction.create(8, 0, Rotate.Spawn)).contains(MinimalAction.create(7, 0, Rotate.Spawn)).contains(MinimalAction.create(6, 0, Rotate.Spawn)).contains(MinimalAction.create(5, 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) Test(org.junit.jupiter.api.Test)

Example 39 with MinoRotation

use of core.srs.MinoRotation 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 40 with MinoRotation

use of core.srs.MinoRotation 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)

Aggregations

MinoRotation (core.srs.MinoRotation)44 MinoFactory (core.mino.MinoFactory)38 Field (core.field.Field)37 MinoShifter (core.mino.MinoShifter)37 Test (org.junit.jupiter.api.Test)32 LongTest (module.LongTest)29 Action (common.datastore.action.Action)25 Piece (core.mino.Piece)17 LockedReachable (core.action.reachable.LockedReachable)16 ColumnField (core.column_field.ColumnField)16 InOutPairField (searcher.pack.InOutPairField)16 Randoms (lib.Randoms)15 LockedCandidate (core.action.candidate.LockedCandidate)14 MinimalAction (common.datastore.action.MinimalAction)12 PermutationIterable (common.iterable.PermutationIterable)12 List (java.util.List)10 PerfectValidator (searcher.common.validator.PerfectValidator)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)8 FieldFactory (core.field.FieldFactory)8