use of core.mino.Mino 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));
}
}
use of core.mino.Mino in project solution-finder by knewjade.
the class MiddleFieldTest method testCanPutMino.
@Test
void testCanPutMino() throws Exception {
String marks = "" + "______X___" + "___X______" + "___XX_____" + "___XX_____" + "___XX_____" + "__X_X_____" + "X___X_____" + "__X_XX____" + "";
Field field = FieldFactory.createMiddleField(marks);
assertThat(field.canPut(new Mino(Piece.T, Rotate.Spawn), 4, 7)).isTrue();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Spawn), 5, 6)).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), 5, 7)).isFalse();
assertThat(field.canPut(new Mino(Piece.T, Rotate.Spawn), 4, 6)).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();
}
use of core.mino.Mino in project solution-finder by knewjade.
the class MiddleFieldTest method testIsOnGround.
@Test
void testIsOnGround() throws Exception {
String marks = "" + "X_________" + "___X______" + "___XX_____" + "___XX_____" + "__X_X_____" + "X___X_____" + "__X_XX____" + "";
Field field = FieldFactory.createMiddleField(marks);
assertThat(field.isOnGround(new Mino(Piece.T, Rotate.Spawn), 1, 7)).isTrue();
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), 1, 6)).isFalse();
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();
}
use of core.mino.Mino 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));
}
}
use of core.mino.Mino in project solution-finder by knewjade.
the class MiddleFieldTest method testPutAndRemoveMino.
@Test
void testPutAndRemoveMino() throws Exception {
Field field = FieldFactory.createMiddleField();
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.put(new Mino(Piece.I, Rotate.Left), 4, 6);
assertThat(field.isEmpty(4, 5)).isFalse();
assertThat(field.isEmpty(4, 6)).isFalse();
assertThat(field.isEmpty(4, 7)).isFalse();
assertThat(field.isEmpty(4, 8)).isFalse();
field.put(new Mino(Piece.O, Rotate.Spawn), 8, 8);
assertThat(field.isEmpty(8, 8)).isFalse();
assertThat(field.isEmpty(8, 9)).isFalse();
assertThat(field.isEmpty(9, 8)).isFalse();
assertThat(field.isEmpty(9, 9)).isFalse();
field.remove(new Mino(Piece.T, Rotate.Spawn), 1, 0);
field.remove(new Mino(Piece.I, Rotate.Left), 4, 6);
field.remove(new Mino(Piece.O, Rotate.Spawn), 8, 8);
assertThat(field.isPerfect()).isTrue();
}
Aggregations