use of common.datastore.blocks.LongPieces 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.datastore.blocks.LongPieces 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.datastore.blocks.LongPieces 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.datastore.blocks.LongPieces 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);
}
use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class PercentCoreTest method assertPercentCore.
private void assertPercentCore(Obj obj, double successPercent) throws Exception {
PatternGenerator generator = new LoadedPatternGenerator(obj.patterns);
NormalEnumeratePieces enumeratePieces = new NormalEnumeratePieces(generator, obj.maxDepth, obj.isUsingHold);
Set<LongPieces> blocks = enumeratePieces.enumerate();
Injector injector = Guice.createInjector(new BasicModule(obj.maxClearLine));
Optional<ExecutorService> executorService = obj.isSingleThread ? Optional.empty() : Optional.of(injector.getInstance(ExecutorService.class));
LockedCandidateThreadLocal candidateThreadLocal = injector.getInstance(LockedCandidateThreadLocal.class);
LockedReachableThreadLocal reachableThreadLocal = injector.getInstance(LockedReachableThreadLocal.class);
MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
PercentCore percentCore = getPercentCore(obj, executorService.orElse(null), candidateThreadLocal, reachableThreadLocal, minoFactory);
Field field = FieldFactory.createField(obj.marks);
percentCore.run(field, blocks, obj.maxClearLine, obj.maxDepth);
executorService.ifPresent(ExecutorService::shutdown);
assertThat(percentCore.getResultTree().getSuccessPercent()).isEqualTo(successPercent);
}
Aggregations