Search in sources :

Example 1 with ColumnSmallField

use of core.column_field.ColumnSmallField in project solution-finder by knewjade.

the class FilterOnDemandBasicSolutions method addColumnSmallField.

private RecursiveMinoFields addColumnSmallField(ColumnField basicField) {
    Field wallField = createWallField(basicField);
    ColumnSmallField initOuterField = ColumnFieldFactory.createField();
    RecursiveMinoFields recursiveMinoFields = calculate(basicField, initOuterField, wallField);
    return new FilteredRecursiveMinoFields(recursiveMinoFields, solutionFilter);
}
Also used : ColumnField(core.column_field.ColumnField) SmallField(core.field.SmallField) Field(core.field.Field) ColumnSmallField(core.column_field.ColumnSmallField) ColumnSmallField(core.column_field.ColumnSmallField)

Example 2 with ColumnSmallField

use of core.column_field.ColumnSmallField in project solution-finder by knewjade.

the class MinoPackingTaskWidthForWidth2 method createTask.

private PackingTask createTask(PackSearcher searcher, long innerFieldBoard, MinoFieldMemento memento, int index) {
    long fillBoard = searcher.getSizedBit().getFillBoard();
    ColumnSmallField over = ColumnFieldFactory.createField(innerFieldBoard & ~fillBoard);
    ColumnField outerField = searcher.getInOutPairFields().get(index).getOuterField();
    if (over.canMerge(outerField)) {
        over.merge(outerField);
        ColumnSmallField innerField = ColumnFieldFactory.createField(innerFieldBoard & fillBoard);
        return new MinoPackingTaskWidthForWidth2(searcher, innerField, over, memento, index);
    }
    return EMPTY_TASK;
}
Also used : ColumnSmallField(core.column_field.ColumnSmallField) ColumnField(core.column_field.ColumnField)

Example 3 with ColumnSmallField

use of core.column_field.ColumnSmallField 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;
}
Also used : ColumnSmallField(core.column_field.ColumnSmallField) SizedBit(searcher.pack.SizedBit) ColumnField(core.column_field.ColumnField) MinoFieldMemento(searcher.pack.memento.MinoFieldMemento)

Example 4 with ColumnSmallField

use of core.column_field.ColumnSmallField in project solution-finder by knewjade.

the class FullOperationSeparableMino method create.

public static SeparableMino create(FullOperationWithKey operationWithKey, int upperY, int fieldHeight) {
    assert upperY <= 10 : upperY;
    Mino mino = operationWithKey.getMino();
    long deleteKey = operationWithKey.getNeedDeletedKey();
    int y = operationWithKey.getY();
    MinoMask minoMask = MinoMaskFactory.create(fieldHeight, mino, y, deleteKey);
    int x = operationWithKey.getX();
    Field mask = minoMask.getMinoMask(x);
    int lowerY = operationWithKey.getY() + operationWithKey.getMino().getMinY();
    ColumnSmallField columnField = ColumnFieldFactory.createField();
    for (int ny = lowerY; ny <= upperY; ny++) {
        for (int nx = x + mino.getMinX(); nx <= x + mino.getMaxX(); nx++) {
            if (!mask.isEmpty(nx, ny))
                columnField.setBlock(nx, ny, fieldHeight);
        }
    }
    Field field = FieldFactory.createField(fieldHeight);
    field.put(operationWithKey.getMino(), operationWithKey.getX(), operationWithKey.getY());
    field.insertWhiteLineWithKey(operationWithKey.getNeedDeletedKey());
    return new FullOperationSeparableMino(operationWithKey, columnField, field);
}
Also used : Field(core.field.Field) ColumnField(core.column_field.ColumnField) ColumnSmallField(core.column_field.ColumnSmallField) ColumnSmallField(core.column_field.ColumnSmallField) MinoMask(searcher.pack.separable_mino.mask.MinoMask) Mino(core.mino.Mino)

Example 5 with ColumnSmallField

use of core.column_field.ColumnSmallField in project solution-finder by knewjade.

the class InOutPairFieldTest method createMaxOuterBoard2x5.

@Test
void createMaxOuterBoard2x5() {
    Field field = FieldFactory.createField("" + "____X___X_" + "___X___XX_" + "__X___XX_X" + "_X___XX__X" + "X____X___X");
    int width = 2;
    int height = 5;
    SizedBit sizedBit = new SizedBit(width, height);
    ColumnSmallField maxOuterBoard = InOutPairField.createMaxOuterBoard(sizedBit, field);
    ColumnSmallField expects = ColumnFieldFactory.createField("" + "_____" + "_____" + "_____" + "_____" + "_____", height);
    assertThat(maxOuterBoard).isEqualTo(expects);
}
Also used : Field(core.field.Field) ColumnSmallField(core.column_field.ColumnSmallField) ColumnSmallField(core.column_field.ColumnSmallField) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnSmallField (core.column_field.ColumnSmallField)18 Field (core.field.Field)11 ColumnField (core.column_field.ColumnField)8 Test (org.junit.jupiter.api.Test)7 SmallField (core.field.SmallField)3 SizedBit (searcher.pack.SizedBit)2 MinoFieldMemento (searcher.pack.memento.MinoFieldMemento)2 ColumnFieldFactory (core.column_field.ColumnFieldFactory)1 Mino (core.mino.Mino)1 EntryPoint (entry.EntryPoint)1 ArrayList (java.util.ArrayList)1 Stream (java.util.stream.Stream)1 Randoms (lib.Randoms)1 SeparableMinos (searcher.pack.SeparableMinos)1 SolutionFilter (searcher.pack.memento.SolutionFilter)1 MemorizedRecursiveMinoFields (searcher.pack.mino_fields.MemorizedRecursiveMinoFields)1 MinoFields (searcher.pack.mino_fields.MinoFields)1 OnDemandRecursiveMinoFields (searcher.pack.mino_fields.OnDemandRecursiveMinoFields)1 RecursiveMinoFields (searcher.pack.mino_fields.RecursiveMinoFields)1 MinoMask (searcher.pack.separable_mino.mask.MinoMask)1