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());
}
Aggregations