use of _implements.parity_based_pack.step1.DeltaLimitedMino in project solution-finder by knewjade.
the class Main3 method search.
public static List<List<MinoOperationWithKey>> search(List<Piece> usedPieces, Field field, int maxClearLine, Field verifyField) {
MinoFactory minoFactory = new MinoFactory();
PositionLimitParser positionLimitParser = new PositionLimitParser(minoFactory, maxClearLine);
LockedReachableThreadLocal threadLocal = new LockedReachableThreadLocal(maxClearLine);
ParityField parityField = new ParityField(field);
PieceCounter pieceCounter = new PieceCounter(usedPieces);
ColumnParityLimitation limitation = new ColumnParityLimitation(pieceCounter, parityField, maxClearLine);
return limitation.enumerate().parallelStream().map(EstimateBuilder::create).flatMap(Collection::stream).flatMap((List<DeltaLimitedMino> deltaLimitedMinos) -> {
// 変換 DeltaLimitedMinos to FullLimitedMino
List<List<FullLimitedMino>> collect = deltaLimitedMinos.stream().map(positionLimitParser::parse).collect(Collectors.toList());
// 候補数が小さい順 // 同種のブロックを固めるため
List<Piece> priority = collect.stream().sorted(Comparator.comparingInt(List::size)).map(fullLimitedMinos -> fullLimitedMinos.get(0).getMino().getPiece()).collect(Collectors.toList());
// ソートする
collect.sort((o1, o2) -> {
int compare = Integer.compare(priority.indexOf(o1.get(0).getMino().getPiece()), priority.indexOf(o2.get(0).getMino().getPiece()));
if (compare != 0)
return compare;
return -Integer.compare(o1.size(), o2.size());
});
return Stream.of(collect);
}).limit(Long.MAX_VALUE).flatMap(sets -> new CrossBuilder(sets, field, maxClearLine).create().stream()).filter(operationWithKeys -> BuildUp.existsValidBuildPattern(verifyField, operationWithKeys, maxClearLine, threadLocal.get())).collect(Collectors.toList());
}
Aggregations