Search in sources :

Example 1 with ReverseOrderLookUp

use of common.order.ReverseOrderLookUp in project solution-finder by knewjade.

the class PathCore method getPiecesPattern.

private HashSet<LongPieces> getPiecesPattern(HashSet<LongPieces> piecesSolution) {
    if (isHoldReduced) {
        // allとvalidが異なる
        ReverseOrderLookUp reverseOrderLookUp = new ReverseOrderLookUp(maxDepth, maxDepth + 1);
        return piecesSolution.stream().filter(validPieces::contains).flatMap(blocks -> {
            return reverseOrderLookUp.parse(blocks.getPieces()).map(stream -> stream.collect(Collectors.toCollection(ArrayList::new))).flatMap(blocksWithHold -> {
                int nullIndex = blocksWithHold.indexOf(null);
                if (nullIndex < 0)
                    return Stream.of(new LongPieces(blocksWithHold));
                Stream.Builder<LongPieces> builder = Stream.builder();
                for (Piece piece : Piece.values()) {
                    blocksWithHold.set(nullIndex, piece);
                    builder.accept(new LongPieces(blocksWithHold));
                }
                return builder.build();
            });
        }).filter(allPieces::contains).collect(Collectors.toCollection(HashSet::new));
    } else if (isUsingHold) {
        // allとvalidが同じだが、ホールドが使える
        ReverseOrderLookUp reverseOrderLookUp = new ReverseOrderLookUp(maxDepth, maxDepth);
        return piecesSolution.stream().filter(validPieces::contains).flatMap(blocks -> {
            return reverseOrderLookUp.parse(blocks.getPieces()).map(stream -> stream.collect(Collectors.toCollection(ArrayList::new))).flatMap(blocksWithHold -> {
                int nullIndex = blocksWithHold.indexOf(null);
                if (nullIndex < 0)
                    return Stream.of(new LongPieces(blocksWithHold));
                Stream.Builder<LongPieces> builder = Stream.builder();
                for (Piece piece : Piece.values()) {
                    blocksWithHold.set(nullIndex, piece);
                    builder.accept(new LongPieces(blocksWithHold));
                }
                return builder.build();
            });
        }).filter(allPieces::contains).collect(Collectors.toCollection(HashSet::new));
    } else {
        // そのまま絞り込みだけ実施
        return piecesSolution.stream().filter(validPieces::contains).collect(Collectors.toCollection(HashSet::new));
    }
}
Also used : SyntaxException(common.SyntaxException) java.util(java.util) Pieces(common.datastore.blocks.Pieces) BlockField(common.datastore.BlockField) LongPieces(common.datastore.blocks.LongPieces) PatternGenerator(common.pattern.PatternGenerator) MinoOperationWithKey(common.datastore.MinoOperationWithKey) SizedBit(searcher.pack.SizedBit) OrderLookup(common.order.OrderLookup) Operation(common.datastore.Operation) FieldFactory(core.field.FieldFactory) StackOrder(common.order.StackOrder) BuildUpStream(common.buildup.BuildUpStream) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) OperationWithKey(common.datastore.OperationWithKey) ReverseOrderLookUp(common.order.ReverseOrderLookUp) Piece(core.mino.Piece) Result(searcher.pack.task.Result) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Field(core.field.Field) Stream(java.util.stream.Stream) SeparableMino(searcher.pack.separable_mino.SeparableMino) FumenParser(entry.path.output.FumenParser) Mino(core.mino.Mino) ReverseOrderLookUp(common.order.ReverseOrderLookUp) LongPieces(common.datastore.blocks.LongPieces) Piece(core.mino.Piece) BuildUpStream(common.buildup.BuildUpStream) Stream(java.util.stream.Stream)

Aggregations

SyntaxException (common.SyntaxException)1 BuildUpStream (common.buildup.BuildUpStream)1 BlockField (common.datastore.BlockField)1 MinoOperationWithKey (common.datastore.MinoOperationWithKey)1 Operation (common.datastore.Operation)1 OperationWithKey (common.datastore.OperationWithKey)1 LongPieces (common.datastore.blocks.LongPieces)1 Pieces (common.datastore.blocks.Pieces)1 OrderLookup (common.order.OrderLookup)1 ReverseOrderLookUp (common.order.ReverseOrderLookUp)1 StackOrder (common.order.StackOrder)1 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)1 PatternGenerator (common.pattern.PatternGenerator)1 Field (core.field.Field)1 FieldFactory (core.field.FieldFactory)1 Mino (core.mino.Mino)1 Piece (core.mino.Piece)1 FumenParser (entry.path.output.FumenParser)1 java.util (java.util)1 ExecutionException (java.util.concurrent.ExecutionException)1