Search in sources :

Example 11 with ColumnSmallField

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

the class InOutPairField method parse.

private static InOutPairField parse(Field field, int width, int height) {
    ColumnSmallField innerField = ColumnFieldFactory.createField();
    ColumnSmallField outerField = ColumnFieldFactory.createField();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (!field.isEmpty(x, y))
                innerField.setBlock(x, y, height);
        }
        for (int x = width; x < width * 2; x++) {
            if (!field.isEmpty(x, y))
                outerField.setBlock(x, y, height);
        }
    }
    return new InOutPairField(innerField, outerField);
}
Also used : ColumnSmallField(core.column_field.ColumnSmallField)

Example 12 with ColumnSmallField

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

the class InOutPairField method parseLast.

private static InOutPairField parseLast(Field field, int width, int height) {
    ColumnSmallField innerField = ColumnFieldFactory.createField();
    ColumnSmallField outerField = ColumnFieldFactory.createField();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (!field.isEmpty(x, y))
                innerField.setBlock(x, y, height);
        }
        for (int x = width; x < width + 3; x++) {
            if (!field.isEmpty(x, y))
                outerField.setBlock(x, y, height);
        }
    }
    return new InOutPairField(innerField, outerField);
}
Also used : ColumnSmallField(core.column_field.ColumnSmallField)

Example 13 with ColumnSmallField

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

the class InOutPairField method createInnerFields.

private static List<ColumnField> createInnerFields(int width, int height, Field initField, int max) {
    ArrayList<ColumnField> fields = new ArrayList<>();
    Field field = initField.freeze(height);
    for (int count = 0; count < max; count++) {
        ColumnSmallField innerField = ColumnFieldFactory.createField();
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                if (!field.isEmpty(x, y))
                    innerField.setBlock(x, y, height);
            }
        }
        fields.add(innerField);
        field.slideLeft(width);
    }
    return fields;
}
Also used : Field(core.field.Field) ColumnField(core.column_field.ColumnField) ColumnSmallField(core.column_field.ColumnSmallField) ColumnSmallField(core.column_field.ColumnSmallField) ColumnField(core.column_field.ColumnField) ArrayList(java.util.ArrayList)

Example 14 with ColumnSmallField

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

the class InOutPairFieldTest method createInOutPairFields3x4.

@Test
void createInOutPairFields3x4() {
    Field field = FieldFactory.createField("" + "___X__X_XX" + "__X__XXXX_" + "_X__XX_XX_" + "X___X__X_X");
    int width = 3;
    int height = 4;
    SizedBit sizedBit = new SizedBit(width, height);
    // Create pairs
    List<InOutPairField> fields = InOutPairField.createInOutPairFields(sizedBit, field);
    assertThat(fields).hasSize(3);
    // Check inner
    ColumnSmallField innerField1 = ColumnFieldFactory.createField("" + "___" + "__X" + "_X_" + "X__", height);
    ColumnSmallField innerField2 = ColumnFieldFactory.createField("" + "X__" + "__X" + "_XX" + "_X_", height);
    ColumnSmallField innerField3 = ColumnFieldFactory.createField("" + "X_X" + "XXX" + "_XX" + "_X_", height);
    assertThat(fields.stream().map(InOutPairField::getInnerField)).containsExactly(innerField1, innerField2, innerField3);
    // Check outer
    ColumnSmallField outerField1 = ColumnFieldFactory.createField("" + "___X__" + "_____X" + "____XX" + "____X_", height);
    ColumnSmallField outerField2 = ColumnFieldFactory.createField("" + "___X_X" + "___XXX" + "____XX" + "____X_", height);
    ColumnSmallField outerField3 = ColumnFieldFactory.createField("" + "___XXX" + "____XX" + "____XX" + "___XXX", height);
    assertThat(fields.stream().map(InOutPairField::getOuterField)).containsExactly(outerField1, outerField2, outerField3);
}
Also used : Field(core.field.Field) ColumnSmallField(core.column_field.ColumnSmallField) ColumnSmallField(core.column_field.ColumnSmallField) Test(org.junit.jupiter.api.Test)

Example 15 with ColumnSmallField

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

the class InOutPairFieldTest method createMaxOuterBoard3x4_2.

@Test
void createMaxOuterBoard3x4_2() {
    Field field = FieldFactory.createField("" + "___X__X_X_" + "__X__XXXX_" + "_X__XX_XX_" + "X___X__X_X");
    int width = 3;
    int height = 4;
    SizedBit sizedBit = new SizedBit(width, height);
    ColumnSmallField maxOuterBoard = InOutPairField.createMaxOuterBoard(sizedBit, field);
    ColumnSmallField expects = ColumnFieldFactory.createField("" + "______" + "_____X" + "____XX" + "____X_", 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