use of core.mino.Mino 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();
}
}
use of core.mino.Mino 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));
}
}
use of core.mino.Mino in project solution-finder by knewjade.
the class SmallFieldTest method testCanPutPiece.
@Test
void testCanPutPiece() {
Randoms randoms = new Randoms();
SmallField field = createRandomSmallField(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));
}
}
use of core.mino.Mino in project solution-finder by knewjade.
the class SmallFieldTest method testPutAndRemoveMino.
@Test
void testPutAndRemoveMino() throws Exception {
Field field = FieldFactory.createSmallField();
field.put(new Mino(Piece.T, Rotate.Spawn), 1, 0);
assertThat(field.isEmpty(0, 0)).isFalse();
assertThat(field.isEmpty(1, 0)).isFalse();
assertThat(field.isEmpty(2, 0)).isFalse();
assertThat(field.isEmpty(1, 1)).isFalse();
field.remove(new Mino(Piece.T, Rotate.Spawn), 1, 0);
assertThat(field.isPerfect()).isTrue();
}
use of core.mino.Mino in project solution-finder by knewjade.
the class SmallFieldTest method testCanPutMino.
@Test
void testCanPutMino() throws Exception {
String marks = "" + "___X______" + "___XX_____" + "__X_X_____" + "X___X_____" + "__X_XX____" + "";
Field field = FieldFactory.createSmallField(marks);
assertThat(field.canPut(new Mino(Piece.T, Rotate.Spawn), 5, 4)).isTrue();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Right), 1, 1)).isTrue();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Reverse), 1, 3)).isTrue();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Left), 3, 1)).isTrue();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Spawn), 3, 0)).isFalse();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Right), 0, 1)).isFalse();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Reverse), 1, 1)).isFalse();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Left), 1, 1)).isFalse();
}
Aggregations