use of lib.Randoms in project solution-finder by knewjade.
the class PiecesNameComparatorTest method compareDiffRandom.
@Test
void compareDiffRandom() throws Exception {
List<Piece> allPieces = Arrays.asList(Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L, Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L);
Randoms randoms = new Randoms();
for (int count = 0; count < 10000; count++) {
List<Piece> blocks1 = randoms.sample(allPieces, randoms.nextInt(10));
List<Piece> blocks2 = randoms.sample(allPieces, randoms.nextInt(10));
if (blocks1.equals(blocks2))
blocks1.add(Piece.O);
LongPieces pieces1 = new LongPieces(blocks1);
LongPieces pieces2 = new LongPieces(blocks2);
// assert is not 0 & sign reversed
PiecesNameComparator comparator = new PiecesNameComparator();
assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
}
}
use of lib.Randoms in project solution-finder by knewjade.
the class PiecesNumberComparatorTest method compareDiffRandom.
@Test
void compareDiffRandom() throws Exception {
List<Piece> allPieces = Arrays.asList(Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L, Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L);
Randoms randoms = new Randoms();
for (int count = 0; count < 10000; count++) {
List<Piece> blocks1 = randoms.sample(allPieces, randoms.nextInt(10));
List<Piece> blocks2 = randoms.sample(allPieces, randoms.nextInt(10));
if (blocks1.equals(blocks2))
blocks1.add(Piece.O);
LongPieces pieces1 = new LongPieces(blocks1);
LongPieces pieces2 = new LongPieces(blocks2);
// assert is not 0 & sign reversed
PiecesNumberComparator comparator = new PiecesNumberComparator();
assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
}
}
use of lib.Randoms in project solution-finder by knewjade.
the class FullOperationSeparableMinoComparatorTest method compareMinoFieldEqual.
@Test
void compareMinoFieldEqual() {
List<SeparableMino> minos = separableMinos.getMinos();
Randoms randoms = new Randoms();
int index = randoms.nextInt(minos.size());
SeparableMino mino = minos.get(index);
FullOperationSeparableMinoComparator comparator = new FullOperationSeparableMinoComparator();
assertThat(comparator.compare(mino, mino)).isEqualTo(0);
}
use of lib.Randoms in project solution-finder by knewjade.
the class MinoFieldComparatorTest method compareMinoFieldDiffOuterField.
@Test
void compareMinoFieldDiffOuterField() {
Randoms randoms = new Randoms();
List<SeparableMino> minos = separableMinos.getMinos();
int index = randoms.nextInt(0, minos.size() - 1);
SeparableMino mino = minos.get(index);
RecursiveMinoField recursiveMinoField1 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
RecursiveMinoField recursiveMinoField2 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(1L), separableMinos);
MinoFieldComparator comparator = new MinoFieldComparator();
assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2)).isEqualTo(0);
}
use of lib.Randoms in project solution-finder by knewjade.
the class MinoFieldComparatorTest method compareMinoFieldEqual.
@Test
void compareMinoFieldEqual() {
Randoms randoms = new Randoms();
List<SeparableMino> minos = separableMinos.getMinos();
SeparableMino mino = minos.get(0);
RecursiveMinoField recursiveMinoField1 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
RecursiveMinoField recursiveMinoField2 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
for (int count = 0; count < 10; count++) {
int index = randoms.nextInt(0, minos.size() - 1);
SeparableMino randomMino = minos.get(index);
recursiveMinoField1 = new RecursiveMinoField(randomMino, recursiveMinoField1, ColumnFieldFactory.createField(), separableMinos);
recursiveMinoField2 = new RecursiveMinoField(randomMino, recursiveMinoField2, ColumnFieldFactory.createField(), separableMinos);
}
MinoFieldComparator comparator = new MinoFieldComparator();
assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2)).isEqualTo(0);
}
Aggregations