use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateNoHoldMulti.
@Test
void enumerateNoHoldMulti() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator(Arrays.asList("T, J, O, Z", "J, O, S, T", "T, J, O, I"));
NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 3, false);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(2);
assertThat(core.getCounter()).isEqualTo(3);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateOverRandomNoHold.
@Test
void enumerateOverRandomNoHold() throws Exception {
List<Piece> failedPieces = Arrays.asList(Piece.I, Piece.O, Piece.L, Piece.J, Piece.S, Piece.Z);
List<Piece> allPieces = new ArrayList<>(Piece.valueList());
for (int size = 1; size <= 7; size++) {
PatternGenerator blocksGenerator = new LoadedPatternGenerator("T, *p" + size);
NormalEnumeratePieces core = new NormalEnumeratePieces(blocksGenerator, size, false);
Set<LongPieces> pieces = core.enumerate();
for (int count = 0; count < 1000; count++) {
List<Piece> sample = new ArrayList<>();
sample.add(Piece.T);
Collections.shuffle(allPieces);
sample.addAll(allPieces.subList(0, size - 1));
assertThat(new LongPieces(sample)).isIn(pieces);
for (Piece piece : failedPieces) {
sample.set(0, piece);
assertThat(new LongPieces(sample)).isNotIn(pieces);
}
}
}
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateHoldOverOne.
@Test
void enumerateHoldOverOne() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("I, S, Z, O, T, J, L");
NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 4, true);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(1);
assertThat(core.getCounter()).isEqualTo(1);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateNoHoldOver3.
@Test
void enumerateNoHoldOver3() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("I, *p7");
NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 4, false);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(210);
assertThat(core.getCounter()).isEqualTo(5040);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateNoHoldOver2.
@Test
void enumerateNoHoldOver2() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("*p7");
NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 4, false);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(840);
assertThat(core.getCounter()).isEqualTo(5040);
}
Aggregations