Search in sources :

Example 16 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch10.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch10(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("T, *p4");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: Nilgiri: https://docs.google.com/spreadsheets/d/1bVY3t_X96xRmUL0qdgB9tViSIGenu6RMKX4RW7qWg8Y/edit#gid=0
    assertThat(tree.getSuccessPercent()).isEqualTo(744 / 840.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 17 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch5.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch5(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("J, I, Z, *p4");
    int maxClearLine = 4;
    int maxDepth = 6;
    String marks = "" + "________XX" + "XX_____XXX" + "XXX_____XX" + "XXX______X" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(771 / 840.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 18 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch4.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch4(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p4");
    int maxClearLine = 3;
    int maxDepth = 3;
    String marks = "" + "XXX____XXX" + "XXX_____XX" + "XXXX___XXX" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(434 / 840.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 19 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method testSearch6.

@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void testSearch6(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws Exception {
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p5");
    int maxClearLine = 4;
    int maxDepth = 4;
    String marks = "" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "";
    ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
    AnalyzeTree tree = runTestCase(invoker, marks, blocksGenerator, maxClearLine, maxDepth);
    // Source: twitter by @???
    assertThat(tree.getSuccessPercent()).isEqualTo(1776 / 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)

Example 20 with ArgumentsSource

use of org.junit.jupiter.params.provider.ArgumentsSource in project solution-finder by knewjade.

the class CheckerUsingHoldInvokerTest method random.

@LongTest
@ParameterizedTest
@ArgumentsSource(InvokerTestCase.class)
void random(IntFunction<ConcurrentCheckerInvoker> invokerGenerator) throws FinderExecuteException, SyntaxException {
    Randoms randoms = new Randoms();
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    for (int count = 0; count < 20; count++) {
        int maxClearLine = randoms.nextInt(3, 6);
        int maxDepth = randoms.nextIntClosed(3, 5);
        Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
        Field field = randoms.field(maxClearLine, maxDepth);
        PatternGenerator blocksGenerator = createPiecesGenerator(maxDepth);
        List<Pieces> searchingPieces = blocksGenerator.blocksStream().collect(Collectors.toList());
        Injector injector = Guice.createInjector(new BasicModule(maxClearLine));
        ExecutorService executorService = injector.getInstance(ExecutorService.class);
        ConcurrentCheckerInvoker invoker = invokerGenerator.apply(maxClearLine);
        List<Pair<Pieces, Boolean>> resultPairs = invoker.search(field, searchingPieces, maxClearLine, maxDepth);
        // 結果を集計する
        AnalyzeTree tree1 = new AnalyzeTree();
        for (Pair<Pieces, Boolean> resultPair : resultPairs) {
            Pieces pieces1 = resultPair.getKey();
            Boolean result = resultPair.getValue();
            tree1.set(result, pieces1);
        }
        System.out.println(tree1.show());
        executorService.shutdown();
        AnalyzeTree tree = tree1;
        for (Pieces pieces : searchingPieces) {
            boolean check = checker.check(field, pieces.getPieces(), candidate, maxClearLine, maxDepth);
            assertThat(tree.isSucceed(pieces)).isEqualTo(check);
        }
    }
}
Also used : Action(common.datastore.action.Action) BasicModule(module.BasicModule) LockedCandidate(core.action.candidate.LockedCandidate) Field(core.field.Field) Injector(com.google.inject.Injector) MinoFactory(core.mino.MinoFactory) PerfectValidator(searcher.common.validator.PerfectValidator) Pieces(common.datastore.blocks.Pieces) Pair(common.datastore.Pair) PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) MinoRotation(core.srs.MinoRotation) Randoms(lib.Randoms) CheckerUsingHold(searcher.checker.CheckerUsingHold) ExecutorService(java.util.concurrent.ExecutorService) MinoShifter(core.mino.MinoShifter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)49 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)27 PatternGenerator (common.pattern.PatternGenerator)27 AnalyzeTree (common.tree.AnalyzeTree)27 LongTest (module.LongTest)16 Log (_usecase.Log)10 TestCase (com.cadenzauk.core.junit.TestCase)7 TestDatabase.testDatabase (com.cadenzauk.siesta.model.TestDatabase.testDatabase)7 Action (common.datastore.action.Action)7 Field (core.field.Field)7 UncheckedAutoCloseable (com.cadenzauk.core.lang.UncheckedAutoCloseable)6 LockedCandidate (core.action.candidate.LockedCandidate)6 Piece (core.mino.Piece)5 LockedReachable (core.action.reachable.LockedReachable)4 RandomValues.randomZonedDateTime (com.cadenzauk.core.RandomValues.randomZonedDateTime)3 TestRow (com.cadenzauk.siesta.model.TestRow)3 MinoFactory (core.mino.MinoFactory)3 MinoShifter (core.mino.MinoShifter)3 MinoRotation (core.srs.MinoRotation)3