use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class CheckerUsingHoldInvokerTest method testSearch2BT4_5.
@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch2BT4_5(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p7");
int maxClearLine = 6;
int maxDepth = 7;
String marks = "" + "XX________" + "XX________" + "XXX______X" + "XXXXXXX__X" + "XXXXXX___X" + "XXXXXXX_XX" + "";
ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
// Source: myself 20170415
assertThat(tree.getSuccessPercent()).isEqualTo(5038 / 5040.0);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class HoldBreakEnumeratePiecesTest method enumerateOverAny.
@Test
void enumerateOverAny() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("T, J, O, Z");
HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(8);
assertThat(core.getCounter()).isEqualTo(1);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class HoldBreakEnumeratePiecesTest method enumerateJust.
@Test
void enumerateJust() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("*p3");
HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(210);
assertThat(core.getCounter()).isEqualTo(210);
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class HoldBreakEnumeratePiecesTest method enumerateOverRandom.
@Test
void enumerateOverRandom() throws Exception {
Randoms randoms = new Randoms();
for (int size = 3; size <= 15; size++) {
List<Piece> blocks = randoms.blocks(size);
String pattern = blocks.stream().map(Piece::getName).collect(Collectors.joining(","));
PatternGenerator blocksGenerator = new LoadedPatternGenerator(pattern);
HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(blocksGenerator, size - 1);
Set<LongPieces> pieces = core.enumerate();
for (int count = 0; count < 10000; count++) {
ArrayList<Piece> sample = new ArrayList<>();
int holdIndex = 0;
for (int index = 1; index < size; index++) {
if (randoms.nextBoolean(0.3)) {
// そのまま追加
sample.add(blocks.get(index));
} else {
// ホールドを追加
sample.add(blocks.get(holdIndex));
holdIndex = index;
}
}
assertThat(new LongPieces(sample)).isIn(pieces);
}
}
}
use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class NormalEnumeratePiecesTest method enumerateHoldOver1.
@Test
void enumerateHoldOver1() throws Exception {
PatternGenerator generator = new LoadedPatternGenerator("*p7");
NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 3, true);
Set<LongPieces> pieces = core.enumerate();
assertThat(pieces).hasSize(840);
assertThat(core.getCounter()).isEqualTo(5040);
}
Aggregations