use of lib.Randoms in project solution-finder by knewjade.
the class PassedMinoShifterTest method enumerateSameOtherActions.
@Test
void enumerateSameOtherActions() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int x = randoms.nextInt(10);
int y = randoms.nextInt(0, 12);
List<Action> actions = minoShifter.enumerateSameOtherActions(piece, rotate, x, y);
assertThat(actions).isEmpty();
}
}
use of lib.Randoms in project solution-finder by knewjade.
the class PassedMinoShifterTest method createTransformedAction.
@Test
void createTransformedAction() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int x = randoms.nextInt(10);
int y = randoms.nextInt(0, 12);
MinimalAction action = MinimalAction.create(x, y, rotate);
Action actualAction = minoShifter.createTransformedAction(piece, action);
assertThat(actualAction).isEqualTo(action);
}
}
use of lib.Randoms in project solution-finder by knewjade.
the class PassedMinoShifterTest method createTransformedRotate.
@Test
void createTransformedRotate() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
Rotate actualRotate = minoShifter.createTransformedRotate(piece, rotate);
assertThat(actualRotate).isEqualTo(rotate);
}
}
use of lib.Randoms in project solution-finder by knewjade.
the class NeighborTest method getNextRightRotateSources.
@Test
void getNextRightRotateSources() {
OriginalPiece piece = new OriginalPiece(new Mino(Piece.T, Rotate.Spawn), 1, 0, 4);
Neighbor neighbor = new Neighbor(piece);
OriginalPieceFactory factory = new OriginalPieceFactory(4);
List<OriginalPiece> pieces = new ArrayList<>(factory.create());
Randoms randoms = new Randoms();
List<Neighbor> samples = randoms.sample(pieces, 4).stream().map(Neighbor::new).collect(Collectors.toList());
neighbor.updateRightRotateSource(samples);
assertThat(neighbor.getNextRightRotateSources()).containsAll(samples);
}
use of lib.Randoms in project solution-finder by knewjade.
the class FieldViewTest method testRandom.
@Test
void testRandom() {
Randoms randoms = new Randoms();
String lineSeparator = System.lineSeparator();
int width = 10;
for (int count = 0; count < 10000; count++) {
int height = randoms.nextIntClosed(1, 12);
boolean[][] fields = new boolean[height][width];
for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) fields[y][x] = randoms.nextBoolean();
StringBuilder builder = new StringBuilder();
for (int y = height - 1; 0 <= y; y--) {
for (int x = 0; x < width; x++) {
boolean isEmpty = fields[y][x];
builder.append(isEmpty ? '_' : 'X');
}
if (y != 0)
builder.append(lineSeparator);
}
String marks = builder.toString();
Field field = FieldFactory.createField(marks.replace(lineSeparator, ""));
String string = FieldView.toString(field, height);
assertThat(string).isEqualTo(marks);
}
}
Aggregations