Search in sources :

Example 1 with UsingBlockAndValidKeySolutionFilter

use of searcher.pack.memento.UsingBlockAndValidKeySolutionFilter 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 2 with UsingBlockAndValidKeySolutionFilter

use of searcher.pack.memento.UsingBlockAndValidKeySolutionFilter 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

PieceCounter (common.datastore.PieceCounter)2 CombinationIterable (common.iterable.CombinationIterable)2 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)2 Piece (core.mino.Piece)2 UsingBlockAndValidKeySolutionFilter (searcher.pack.memento.UsingBlockAndValidKeySolutionFilter)2 HashSet (java.util.HashSet)1