Search in sources :

Example 26 with Mino

use of core.mino.Mino 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 27 with Mino

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

the class MiddleFieldTest method testGetYOnHarddrop.

@Test
void testGetYOnHarddrop() throws Exception {
    String marks = "" + "X_________" + "__________" + "__________" + "__________" + "_________X" + "____X_____" + "";
    Field field = FieldFactory.createMiddleField(marks);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 1, 10)).isEqualTo(6);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 2, 10)).isEqualTo(0);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 3, 10)).isEqualTo(1);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 8, 10)).isEqualTo(2);
}
Also used : Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 28 with Mino

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

the class SmallFieldTest method testGetYOnHarddrop.

@Test
void testGetYOnHarddrop() throws Exception {
    String marks = "" + "__________" + "_________X" + "____X_____" + "";
    Field field = FieldFactory.createSmallField(marks);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 1, 4)).isEqualTo(0);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 3, 4)).isEqualTo(1);
    assertThat(field.getYOnHarddrop(new Mino(Piece.T, Rotate.Spawn), 8, 4)).isEqualTo(2);
}
Also used : Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 29 with Mino

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

the class SmallFieldTest method testCanPutMino2.

@Test
void testCanPutMino2() throws Exception {
    String marks = "" + "XXXXXXXX_X" + "XXXXXXXX_X" + "XXXXXXXX_X" + "XXXXXXXX_X" + "XXXXXXXX_X" + "XXXXXXXX_X";
    Field field = FieldFactory.createSmallField(marks);
    assertThat(field.canPut(new Mino(Piece.I, Rotate.Left), 8, 1)).isTrue();
    assertThat(field.canPut(new Mino(Piece.I, Rotate.Left), 8, 6)).isTrue();
    assertThat(field.canPut(new Mino(Piece.I, Rotate.Left), 8, 7)).isTrue();
    assertThat(field.canPut(new Mino(Piece.I, Rotate.Left), 8, 8)).isTrue();
    assertThat(field.canPut(new Mino(Piece.I, Rotate.Left), 8, 9)).isTrue();
}
Also used : Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 30 with Mino

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

the class SmallFieldTest method testIsOnGround.

@Test
void testIsOnGround() throws Exception {
    String marks = "" + "___X______" + "___XX_____" + "___XX_____" + "__X_X_____" + "X___X_____" + "__X_XX____" + "";
    Field field = FieldFactory.createSmallField(marks);
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Spawn), 5, 5)).isTrue();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Right), 8, 1)).isTrue();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Reverse), 1, 3)).isTrue();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Left), 1, 2)).isTrue();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Spawn), 6, 5)).isFalse();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Spawn), 8, 1)).isFalse();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Right), 8, 2)).isFalse();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Reverse), 7, 3)).isFalse();
    assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Left), 9, 2)).isFalse();
}
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