Search in sources :

Example 1 with OriginalPieceFactory

use of core.neighbor.OriginalPieceFactory 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 2 with OriginalPieceFactory

use of core.neighbor.OriginalPieceFactory 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)

Aggregations

OriginalPieceFactory (core.neighbor.OriginalPieceFactory)2 Injector (com.google.inject.Injector)1 Field (core.field.Field)1 Mino (core.mino.Mino)1 MinoFactory (core.mino.MinoFactory)1 MinoShifter (core.mino.MinoShifter)1 OriginalPiece (core.neighbor.OriginalPiece)1 MinoRotation (core.srs.MinoRotation)1 Randoms (lib.Randoms)1 BasicModule (module.BasicModule)1 Test (org.junit.jupiter.api.Test)1