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));
}
}
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));
}
}
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);
}
}
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);
}
}
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));
}
}
Aggregations