Search in sources :

Example 1 with OriginalPiece

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

use of core.neighbor.OriginalPiece 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 3 with OriginalPiece

use of core.neighbor.OriginalPiece in project solution-finder by knewjade.

the class MiddleFieldTest method testPutAndRemovePiece.

@Test
void testPutAndRemovePiece() throws Exception {
    MiddleField field = FieldFactory.createMiddleField();
    int maxFieldHeight = field.getMaxFieldHeight();
    ArrayList<OriginalPiece> pieces = createAllPieces(maxFieldHeight);
    for (OriginalPiece piece : pieces) {
        // Initialize
        Mino mino = piece.getMino();
        int x = piece.getX();
        int y = piece.getY();
        // Expect
        MiddleField expected = FieldFactory.createMiddleField();
        expected.put(mino, x, y);
        // Test
        field.put(piece);
        assertThat(field).as("%s (%d, %d)", mino, x, y).isEqualTo(expected);
        field.remove(piece);
        assertThat(field.isPerfect()).as("%s (%d, %d)", mino, x, y).isTrue();
    }
}
Also used : Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) Test(org.junit.jupiter.api.Test)

Example 4 with OriginalPiece

use of core.neighbor.OriginalPiece in project solution-finder by knewjade.

the class SmallFieldTest method testPutAndRemovePiece.

@Test
void testPutAndRemovePiece() throws Exception {
    SmallField field = FieldFactory.createSmallField();
    int maxFieldHeight = field.getMaxFieldHeight();
    ArrayList<OriginalPiece> pieces = createAllPieces(maxFieldHeight);
    for (OriginalPiece piece : pieces) {
        // Initialize
        Mino mino = piece.getMino();
        int x = piece.getX();
        int y = piece.getY();
        // Expect
        SmallField expected = FieldFactory.createSmallField();
        expected.put(mino, x, y);
        // Test
        field.put(piece);
        assertThat(field).as("%s (%d, %d)", mino, x, y).isEqualTo(expected);
        field.remove(piece);
        assertThat(field.isPerfect()).as("%s (%d, %d)", mino, x, y).isTrue();
    }
}
Also used : Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece) Test(org.junit.jupiter.api.Test)

Example 5 with OriginalPiece

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

OriginalPiece (core.neighbor.OriginalPiece)10 Mino (core.mino.Mino)8 Test (org.junit.jupiter.api.Test)7 Randoms (lib.Randoms)5 Neighbor (core.neighbor.Neighbor)3 Injector (com.google.inject.Injector)1 Action (common.datastore.action.Action)1 Field (core.field.Field)1 Piece (core.mino.Piece)1 OriginalPieceFactory (core.neighbor.OriginalPieceFactory)1 Rotate (core.srs.Rotate)1 BasicModule (module.BasicModule)1