Search in sources :

Example 6 with CombinationIterable

use of common.iterable.CombinationIterable in project solution-finder by knewjade.

the class PackSearcherComparingParityBasedOnDemandTest method createUsingBlockAndValidKeyMementoFilter.

// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
    HashSet<Long> validBlockCounters = new HashSet<>();
    for (PieceCounter counter : counters) {
        List<Piece> usingPieces = counter.getBlocks();
        for (int size = 1; size <= usingPieces.size(); size++) {
            CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
            for (List<Piece> pieces : combinationIterable) {
                PieceCounter newCounter = new PieceCounter(pieces);
                validBlockCounters.add(newCounter.getCounter());
            }
        }
    }
    LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
    return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
Also used : CombinationIterable(common.iterable.CombinationIterable) PieceCounter(common.datastore.PieceCounter) Piece(core.mino.Piece) UsingBlockAndValidKeySolutionFilter(searcher.pack.memento.UsingBlockAndValidKeySolutionFilter) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) HashSet(java.util.HashSet)

Example 7 with CombinationIterable

use of common.iterable.CombinationIterable in project solution-finder by knewjade.

the class PackSearcherComparingParityBasedTest method createUsingBlockAndValidKeyMementoFilter.

// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
    HashSet<Long> validBlockCounters = new HashSet<>();
    for (PieceCounter counter : counters) {
        List<Piece> usingPieces = counter.getBlocks();
        for (int size = 1; size <= usingPieces.size(); size++) {
            CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
            for (List<Piece> pieces : combinationIterable) {
                PieceCounter newCounter = new PieceCounter(pieces);
                validBlockCounters.add(newCounter.getCounter());
            }
        }
    }
    LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
    return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
Also used : CombinationIterable(common.iterable.CombinationIterable) PieceCounter(common.datastore.PieceCounter) Piece(core.mino.Piece) UsingBlockAndValidKeySolutionFilter(searcher.pack.memento.UsingBlockAndValidKeySolutionFilter) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal)

Aggregations

CombinationIterable (common.iterable.CombinationIterable)7 Piece (core.mino.Piece)4 ArrayList (java.util.ArrayList)4 FullOperationWithKey (common.datastore.FullOperationWithKey)3 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)3 PieceCounter (common.datastore.PieceCounter)2 Mino (core.mino.Mino)2 Rotate (core.srs.Rotate)2 UsingBlockAndValidKeySolutionFilter (searcher.pack.memento.UsingBlockAndValidKeySolutionFilter)2 ColumnParityLimitation (_implements.parity_based_pack.step1.ColumnParityLimitation)1 DeltaLimitedMino (_implements.parity_based_pack.step1.DeltaLimitedMino)1 EstimateBuilder (_implements.parity_based_pack.step1.EstimateBuilder)1 FullLimitedMino (_implements.parity_based_pack.step2.FullLimitedMino)1 PositionLimitParser (_implements.parity_based_pack.step2.PositionLimitParser)1 CrossBuilder (_implements.parity_based_pack.step3.CrossBuilder)1 BuildUp (common.buildup.BuildUp)1 OperationWithKeyComparator (common.comparator.OperationWithKeyComparator)1 common.datastore (common.datastore)1 OperationWithKeyInterpreter (common.parser.OperationWithKeyInterpreter)1 Tetfu (common.tetfu.Tetfu)1