Search in sources :

Example 61 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator 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);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) BasicModule(module.BasicModule) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) Field(core.field.Field) LongPieces(common.datastore.blocks.LongPieces) Injector(com.google.inject.Injector) LockedCandidateThreadLocal(concurrent.LockedCandidateThreadLocal) NormalEnumeratePieces(entry.searching_pieces.NormalEnumeratePieces) ExecutorService(java.util.concurrent.ExecutorService) MinoFactory(core.mino.MinoFactory)

Aggregations

LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)61 PatternGenerator (common.pattern.PatternGenerator)61 Test (org.junit.jupiter.api.Test)35 LongPieces (common.datastore.blocks.LongPieces)31 AnalyzeTree (common.tree.AnalyzeTree)30 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)25 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)25 Piece (core.mino.Piece)11 Randoms (lib.Randoms)8 LongTest (module.LongTest)7 HashSet (java.util.HashSet)4 Pieces (common.datastore.blocks.Pieces)2 Field (core.field.Field)2 MinoFactory (core.mino.MinoFactory)2 ArrayList (java.util.ArrayList)2 Injector (com.google.inject.Injector)1 Action (common.datastore.action.Action)1 LockedCandidateThreadLocal (concurrent.LockedCandidateThreadLocal)1 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)1 LockedCandidate (core.action.candidate.LockedCandidate)1