use of searcher.pack.memento.MinoFieldMemento in project solution-finder by knewjade.
the class Field4x10MinoPackingHelper method fixResult.
// 高さが4・最後の1列がのこる場合で、パフェできるパターンは2つしか存在しない
@Override
public Stream<Result> fixResult(PackSearcher searcher, long innerFieldBoard, MinoFieldMemento nextMemento) {
SizedBit sizedBit = searcher.getSizedBit();
SolutionFilter solutionFilter = searcher.getSolutionFilter();
if (innerFieldBoard == sizedBit.getFillBoard()) {
if (solutionFilter.testLast(nextMemento))
return Stream.of(createResult(nextMemento));
} else {
assert innerFieldBoard == 0b111111110000L;
MinoFieldMemento concatILeft = nextMemento.concat(LEFT_I_ONLY);
if (solutionFilter.testLast(concatILeft))
return Stream.of(createResult(concatILeft));
}
return Stream.empty();
}
use of searcher.pack.memento.MinoFieldMemento in project solution-finder by knewjade.
the class MinoPackingTaskWidthForWidth2 method split.
private PackingTask split(MinoField minoField) {
ColumnField minoOuterField = minoField.getOuterField();
// 注目範囲外outerで重なりがないか確認
if (outerField.canMerge(minoOuterField)) {
// 有効なおきかた
SizedBit sizedBit = searcher.getSizedBit();
ColumnField mergedOuterField = outerField.freeze(sizedBit.getHeight());
mergedOuterField.merge(minoOuterField);
long innerFieldBoard = mergedOuterField.getBoard(0) >> sizedBit.getMaxBitDigit();
MinoFieldMemento nextMemento = memento.concat(minoField);
return checkAndCreateTask(innerFieldBoard, nextMemento, index + 1);
}
return EMPTY_TASK;
}
use of searcher.pack.memento.MinoFieldMemento in project solution-finder by knewjade.
the class MinoPackingTaskWidthForWidth2 method splitAndFixResult.
private Stream<Result> splitAndFixResult(MinoField minoField) {
ColumnField minoOuterField = minoField.getOuterField();
// 注目範囲外outerで重なりがないか確認
if (outerField.canMerge(minoOuterField)) {
// 有効なおきかた
SizedBit sizedBit = searcher.getSizedBit();
ColumnField mergedOuterField = outerField.freeze(searcher.getSizedBit().getHeight());
mergedOuterField.merge(minoOuterField);
long innerFieldBoard = mergedOuterField.getBoard(0) >> sizedBit.getMaxBitDigit();
MinoFieldMemento nextMemento = memento.concat(minoField);
return searcher.getTaskResultHelper().fixResult(searcher, innerFieldBoard, nextMemento);
}
return Stream.empty();
}
use of searcher.pack.memento.MinoFieldMemento in project solution-finder by knewjade.
the class MinoPackingTaskWidthForWidth2 method compute.
@Override
public Stream<Result> compute() {
if (searcher.isFilled(innerField, index)) {
// innerFieldが埋まっている
if (index == searcher.getLastIndex()) {
// 最後の計算
SizedBit sizedBit = searcher.getSizedBit();
long innerFieldBoard = outerField.getBoard(0) >> sizedBit.getMaxBitDigit();
MinoFieldMemento nextMemento = memento.skip();
return searcher.getTaskResultHelper().fixResult(searcher, innerFieldBoard, nextMemento);
} else {
// 途中の計算 // 自分で計算する
MinoFieldMemento nextMemento = memento.skip();
long innerFieldBoard = outerField.getBoard(0) >> searcher.getSizedBit().getMaxBitDigit();
return createTask(searcher, innerFieldBoard, nextMemento, index + 1).compute();
}
} else {
MinoFields minoFields = searcher.getSolutions(index).parse(innerField);
// innerFieldが埋まっていない
if (index == searcher.getLastIndex()) {
// 最後の計算
return minoFields.stream().parallel().flatMap(this::splitAndFixResult);
} else {
// 途中の計算
return minoFields.stream().parallel().map(this::split).filter(this::isValidTask).flatMap(PackingTask::compute);
}
}
}
use of searcher.pack.memento.MinoFieldMemento in project solution-finder by knewjade.
the class MinoPackingTaskWidthForWidth3 method split.
private PackingTask split(MinoField minoField) {
ColumnField outerField = searcher.getInOutPairFields().get(index).getOuterField();
ColumnField minoOuterField = minoField.getOuterField();
// 注目範囲外outerで重なりがないか確認
if (outerField.canMerge(minoOuterField)) {
// 有効なおきかた
SizedBit sizedBit = searcher.getSizedBit();
ColumnField mergedOuterField = outerField.freeze(sizedBit.getHeight());
mergedOuterField.merge(minoOuterField);
ColumnSmallField nextInnerField = ColumnFieldFactory.createField(mergedOuterField.getBoard(0) >> sizedBit.getMaxBitDigit());
MinoFieldMemento nextMemento = memento.concat(minoField);
return checkAndCreateTask(nextInnerField, nextMemento, index + 1);
}
return EMPTY_TASK;
}
Aggregations