Search in sources :

Example 91 with Mino

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

the class LockedNeighborReachableTest method randoms.

@Test
void randoms() {
    int maxClearLine = 4;
    Injector injector = Guice.createInjector(new BasicModule(maxClearLine));
    LockedReachable reachable1 = createLockedReachable(injector, maxClearLine);
    LockedNeighborReachable reachable2 = createLockedNeighborReachable(injector, maxClearLine);
    OriginalPieceFactory pieceFactory = injector.getInstance(OriginalPieceFactory.class);
    Set<OriginalPiece> pieces = pieceFactory.create();
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        Field field = randoms.field(4, 5);
        for (OriginalPiece piece : pieces) {
            // フィールドにそもそも置けないときは前提条件が合わないためスキップ
            if (!field.canPut(piece))
                continue;
            Mino mino = piece.getMino();
            int x = piece.getX();
            int y = piece.getY();
            boolean checks1 = reachable1.checks(field, mino, x, y, maxClearLine);
            boolean checks2 = reachable2.checks(field, mino, x, y, maxClearLine);
            assertThat(checks2).as(piece.toString()).isEqualTo(checks1);
        }
    }
}
Also used : Field(core.field.Field) Randoms(lib.Randoms) Injector(com.google.inject.Injector) BasicModule(module.BasicModule) Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) OriginalPieceFactory(core.neighbor.OriginalPieceFactory) Test(org.junit.jupiter.api.Test)

Example 92 with Mino

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

the class LockedNeighborReachableTest method checks2.

@Test
void checks2() {
    int maxClearLine = 4;
    Injector injector = Guice.createInjector(new BasicModule(maxClearLine));
    LockedNeighborReachable reachable = createLockedNeighborReachable(injector, maxClearLine);
    Field field = FieldFactory.createField("" + "X______XXX" + "XXXXXX___X" + "XXX_____XX" + "XXX______X");
    boolean checks = reachable.checks(field, new Mino(Piece.J, Rotate.Spawn), 4, 0, maxClearLine);
    assertThat(checks).isFalse();
}
Also used : Field(core.field.Field) Injector(com.google.inject.Injector) BasicModule(module.BasicModule) Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 93 with Mino

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

the class NeighborTest method getNextRightRotateSources.

@Test
void getNextRightRotateSources() {
    OriginalPiece piece = new OriginalPiece(new Mino(Piece.T, Rotate.Spawn), 1, 0, 4);
    Neighbor neighbor = new Neighbor(piece);
    OriginalPieceFactory factory = new OriginalPieceFactory(4);
    List<OriginalPiece> pieces = new ArrayList<>(factory.create());
    Randoms randoms = new Randoms();
    List<Neighbor> samples = randoms.sample(pieces, 4).stream().map(Neighbor::new).collect(Collectors.toList());
    neighbor.updateRightRotateSource(samples);
    assertThat(neighbor.getNextRightRotateSources()).containsAll(samples);
}
Also used : Randoms(lib.Randoms) ArrayList(java.util.ArrayList) Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 94 with Mino

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

the class OriginalPieceTest method testHashCodeDiffFieldHeight.

@Test
void testHashCodeDiffFieldHeight() {
    OriginalPiece piece1 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 10);
    OriginalPiece piece2 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 5);
    assertThat(piece1.hashCode()).isEqualTo(piece2.hashCode());
}
Also used : Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 95 with Mino

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

the class OriginalPieceTest method testEqualsDiffFieldHeight.

@Test
void testEqualsDiffFieldHeight() {
    OriginalPiece piece1 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 10);
    OriginalPiece piece2 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 5);
    assertThat(piece1.equals(piece2)).isTrue();
}
Also used : Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Aggregations

Mino (core.mino.Mino)103 Test (org.junit.jupiter.api.Test)46 Rotate (core.srs.Rotate)27 Field (core.field.Field)24 Piece (core.mino.Piece)20 Randoms (lib.Randoms)16 MinoFactory (core.mino.MinoFactory)14 ColorType (common.tetfu.common.ColorType)12 ColoredField (common.tetfu.field.ColoredField)12 ArrayList (java.util.ArrayList)12 FullOperationWithKey (common.datastore.FullOperationWithKey)9 HashSet (java.util.HashSet)9 ColorConverter (common.tetfu.common.ColorConverter)8 OriginalPiece (core.neighbor.OriginalPiece)8 List (java.util.List)8 MinoOperationWithKey (common.datastore.MinoOperationWithKey)7 OperationWithKey (common.datastore.OperationWithKey)7 TetfuPage (common.tetfu.TetfuPage)7 Arrays (java.util.Arrays)7 Collectors (java.util.stream.Collectors)7