Search in sources :

Example 36 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MiddleFieldTest method testCanReachOnHarddrop2.

@Test
void testCanReachOnHarddrop2() throws Exception {
    Randoms randoms = new Randoms();
    MiddleField field = createRandomMiddleField(randoms);
    String string = FieldView.toString(field);
    ArrayList<OriginalPiece> pieces = createAllPieces(field.getMaxFieldHeight());
    for (OriginalPiece piece : pieces) {
        Mino mino = piece.getMino();
        int x = piece.getX();
        int y = piece.getY();
        assertThat(field.canReachOnHarddrop(piece)).as(string + piece.toString()).isEqualTo(field.canPut(mino, x, y) && field.canReachOnHarddrop(mino, x, y));
    }
}
Also used : Randoms(lib.Randoms) Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) Test(org.junit.jupiter.api.Test)

Example 37 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MiddleFieldTest method testCanPutPiece.

@Test
void testCanPutPiece() {
    Randoms randoms = new Randoms();
    MiddleField field = createRandomMiddleField(randoms);
    int maxFieldHeight = field.getMaxFieldHeight();
    ArrayList<OriginalPiece> pieces = createAllPieces(maxFieldHeight);
    for (OriginalPiece piece : pieces) {
        Mino mino = piece.getMino();
        int x = piece.getX();
        int y = piece.getY();
        assertThat(field.canPut(piece)).as("%s (%d, %d)", mino, x, y).isEqualTo(field.canPut(mino, x, y));
    }
}
Also used : Randoms(lib.Randoms) Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) Test(org.junit.jupiter.api.Test)

Example 38 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MiddleFieldTest method testSlideLeftRandom.

@Test
void testSlideLeftRandom() {
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        int slide = randoms.nextInt(10);
        MiddleField field = FieldFactory.createMiddleField();
        MiddleField expect = FieldFactory.createMiddleField();
        int numOfBlocks = randoms.nextInt(1, 120);
        for (int block = 0; block < numOfBlocks; block++) {
            int x = randoms.nextInt(10);
            int y = randoms.nextInt(0, 12);
            field.setBlock(x, y);
            if (0 <= x - slide)
                expect.setBlock(x - slide, y);
        }
        field.slideLeft(slide);
        assertThat(field).isEqualTo(expect);
    }
}
Also used : Randoms(lib.Randoms) Test(org.junit.jupiter.api.Test)

Example 39 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MiddleFieldTest method testGetLowerYRandom.

@Test
void testGetLowerYRandom() {
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        MiddleField field = FieldFactory.createMiddleField();
        int minY = Integer.MAX_VALUE;
        int numOfBlocks = randoms.nextInt(1, 120);
        for (int block = 0; block < numOfBlocks; block++) {
            int x = randoms.nextInt(10);
            int y = randoms.nextInt(0, 12);
            field.setBlock(x, y);
            if (y < minY)
                minY = y;
        }
        assertThat(field.getLowerY()).isEqualTo(minY);
    }
}
Also used : Randoms(lib.Randoms) Test(org.junit.jupiter.api.Test)

Example 40 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class SmallFieldTest method testCanReachOnHarddrop2.

@Test
void testCanReachOnHarddrop2() throws Exception {
    Randoms randoms = new Randoms();
    SmallField field = createRandomSmallField(randoms);
    String string = FieldView.toString(field);
    ArrayList<OriginalPiece> pieces = createAllPieces(field.getMaxFieldHeight());
    for (OriginalPiece piece : pieces) {
        Mino mino = piece.getMino();
        int x = piece.getX();
        int y = piece.getY();
        assertThat(field.canReachOnHarddrop(piece)).as(string + piece.toString()).isEqualTo(field.canPut(mino, x, y) && field.canReachOnHarddrop(mino, x, y));
    }
}
Also used : Randoms(lib.Randoms) Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) Test(org.junit.jupiter.api.Test)

Aggregations

Randoms (lib.Randoms)108 Test (org.junit.jupiter.api.Test)103 Piece (core.mino.Piece)58 LongTest (module.LongTest)32 Field (core.field.Field)29 Action (common.datastore.action.Action)25 LongPieces (common.datastore.blocks.LongPieces)24 MinoFactory (core.mino.MinoFactory)20 ArrayList (java.util.ArrayList)19 LockedCandidate (core.action.candidate.LockedCandidate)17 Mino (core.mino.Mino)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 MinoShifter (core.mino.MinoShifter)14 MinoRotation (core.srs.MinoRotation)14 Rotate (core.srs.Rotate)13 Collectors (java.util.stream.Collectors)13 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)12 PatternGenerator (common.pattern.PatternGenerator)12 List (java.util.List)12 SeparableMino (searcher.pack.separable_mino.SeparableMino)12