Search in sources :

Example 11 with TaskResultHelper

use of searcher.pack.task.TaskResultHelper in project solution-finder by knewjade.

the class EasyPath method buildUp.

public Set<LongPieces> buildUp(String goalFieldMarks, Field initField, int width, int height) throws ExecutionException, InterruptedException {
    assert !initField.existsAbove(height);
    SizedBit sizedBit = new SizedBit(width, height);
    Field goalField = FieldFactory.createInverseField(goalFieldMarks);
    List<InOutPairField> inOutPairFields = InOutPairField.createInOutPairFields(sizedBit, goalField);
    // Create
    BasicSolutions basicSolutions = createMappedBasicSolutions(sizedBit);
    TaskResultHelper taskResultHelper = new Field4x10MinoPackingHelper();
    // Assert
    SolutionFilter solutionFilter = createSRSSolutionFilter(sizedBit, initField);
    // パフェ手順の列挙
    PerfectPackSearcher searcher = new PerfectPackSearcher(inOutPairFields, basicSolutions, sizedBit, solutionFilter, taskResultHelper);
    LockedReachableThreadLocal reachableThreadLocal = easyPool.getLockedReachableThreadLocal(height);
    List<Result> results = searcher.toList();
    return results.stream().map(Result::getMemento).map(memento -> {
        return memento.getSeparableMinoStream(width).map(SeparableMino::toMinoOperationWithKey).collect(Collectors.toList());
    }).map(operations -> new BuildUpStream(reachableThreadLocal.get(), height).existsValidBuildPattern(initField, operations)).flatMap(listStream -> {
        return listStream.map(operationWithKeys -> {
            Stream<Piece> blocks = operationWithKeys.stream().map(OperationWithKey::getPiece);
            return new LongPieces(blocks);
        });
    }).collect(Collectors.toSet());
}
Also used : TaskResultHelper(searcher.pack.task.TaskResultHelper) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) BasicSolutionsCalculator(searcher.pack.solutions.BasicSolutionsCalculator) LongPieces(common.datastore.blocks.LongPieces) ColumnField(core.column_field.ColumnField) SizedBit(searcher.pack.SizedBit) MinoFactory(core.mino.MinoFactory) Map(java.util.Map) SeparableMinos(searcher.pack.SeparableMinos) FieldFactory(core.field.FieldFactory) BuildUpStream(common.buildup.BuildUpStream) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) OperationWithKey(common.datastore.OperationWithKey) Field4x10MinoPackingHelper(searcher.pack.task.Field4x10MinoPackingHelper) MinoShifter(core.mino.MinoShifter) MappedBasicSolutions(searcher.pack.solutions.MappedBasicSolutions) Piece(core.mino.Piece) Result(searcher.pack.task.Result) InOutPairField(searcher.pack.InOutPairField) Set(java.util.Set) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) SolutionFilter(searcher.pack.memento.SolutionFilter) List(java.util.List) Field(core.field.Field) BasicSolutions(searcher.pack.calculator.BasicSolutions) Stream(java.util.stream.Stream) SeparableMino(searcher.pack.separable_mino.SeparableMino) SRSValidSolutionFilter(searcher.pack.memento.SRSValidSolutionFilter) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) Field4x10MinoPackingHelper(searcher.pack.task.Field4x10MinoPackingHelper) SeparableMino(searcher.pack.separable_mino.SeparableMino) TaskResultHelper(searcher.pack.task.TaskResultHelper) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) MappedBasicSolutions(searcher.pack.solutions.MappedBasicSolutions) BasicSolutions(searcher.pack.calculator.BasicSolutions) Result(searcher.pack.task.Result) ColumnField(core.column_field.ColumnField) InOutPairField(searcher.pack.InOutPairField) Field(core.field.Field) SizedBit(searcher.pack.SizedBit) InOutPairField(searcher.pack.InOutPairField) LongPieces(common.datastore.blocks.LongPieces) SolutionFilter(searcher.pack.memento.SolutionFilter) SRSValidSolutionFilter(searcher.pack.memento.SRSValidSolutionFilter) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) BuildUpStream(common.buildup.BuildUpStream) Stream(java.util.stream.Stream) BuildUpStream(common.buildup.BuildUpStream)

Aggregations

InOutPairField (searcher.pack.InOutPairField)11 TaskResultHelper (searcher.pack.task.TaskResultHelper)11 SizedBit (searcher.pack.SizedBit)10 SolutionFilter (searcher.pack.memento.SolutionFilter)10 PerfectPackSearcher (searcher.pack.task.PerfectPackSearcher)10 ColumnField (core.column_field.ColumnField)9 Field (core.field.Field)9 Field4x10MinoPackingHelper (searcher.pack.task.Field4x10MinoPackingHelper)9 MinoFactory (core.mino.MinoFactory)8 MinoShifter (core.mino.MinoShifter)8 SeparableMinos (searcher.pack.SeparableMinos)8 SeparableMino (searcher.pack.separable_mino.SeparableMino)8 Result (searcher.pack.task.Result)8 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)7 Collectors (java.util.stream.Collectors)7 SRSValidSolutionFilter (searcher.pack.memento.SRSValidSolutionFilter)7 OnDemandBasicSolutions (searcher.pack.solutions.OnDemandBasicSolutions)7 FieldFactory (core.field.FieldFactory)6 Piece (core.mino.Piece)6 MinoRotation (core.srs.MinoRotation)6