Search in sources :

Example 36 with AnalyzeTree

use of common.tree.AnalyzeTree in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method runTestCase.

private AnalyzeTree runTestCase(ConcurrentCheckerInvoker invoker, Field field, List<Pieces> searchingPieces, int maxClearLine, int maxDepth) throws FinderExecuteException {
    List<Pair<Pieces, Boolean>> resultPairs = invoker.search(field, searchingPieces, maxClearLine, maxDepth);
    // 結果を集計する
    AnalyzeTree tree = new AnalyzeTree();
    for (Pair<Pieces, Boolean> resultPair : resultPairs) {
        Pieces pieces = resultPair.getKey();
        Boolean result = resultPair.getValue();
        tree.set(result, pieces);
    }
    System.out.println(tree.show());
    return tree;
}
Also used : Pair(common.datastore.Pair) AnalyzeTree(common.tree.AnalyzeTree) Pieces(common.datastore.blocks.Pieces)

Example 37 with AnalyzeTree

use of common.tree.AnalyzeTree in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method testCase12.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testCase12(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    // Invoker
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p7");
    int maxClearLine = 4;
    int maxDepth = 6;
    // Field
    String marks = "" + "X_________" + "X___X_____" + "XXXXXXX___" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: reply in twitter from @fullfool_14
    assertThat(tree.getSuccessPercent()).isEqualTo(727 / 5040.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 38 with AnalyzeTree

use of common.tree.AnalyzeTree in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch1.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch1(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p7");
    int maxClearLine = 8;
    int maxDepth = 7;
    String marks = "" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXXXX__" + "XXXXXXXX__" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(5032 / 5040.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 39 with AnalyzeTree

use of common.tree.AnalyzeTree in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch3.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch3(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p7");
    int maxClearLine = 4;
    int maxDepth = 6;
    String marks = "" + "X_________" + "X___X_____" + "XXXXXXX___" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(4736 / 5040.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 40 with AnalyzeTree

use of common.tree.AnalyzeTree in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch9.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch9(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXXX____" + "XXXXX_____" + "XXXXXXX___" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: twitter by @???
    assertThat(tree.getSuccessPercent()).isEqualTo(1700 / 2520.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

AnalyzeTree (common.tree.AnalyzeTree)42 PatternGenerator (common.pattern.PatternGenerator)33 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)27 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)27 Field (core.field.Field)10 MinoFactory (core.mino.MinoFactory)9 Test (org.junit.jupiter.api.Test)9 Action (common.datastore.action.Action)8 LockedCandidate (core.action.candidate.LockedCandidate)8 MinoShifter (core.mino.MinoShifter)8 MinoRotation (core.srs.MinoRotation)8 PerfectValidator (searcher.common.validator.PerfectValidator)8 Piece (core.mino.Piece)7 LongTest (module.LongTest)7 Pieces (common.datastore.blocks.Pieces)6 List (java.util.List)5 Pair (common.datastore.Pair)4 PermutationIterable (common.iterable.PermutationIterable)4 LongPieces (common.datastore.blocks.LongPieces)2