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);
}
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);
}
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;
}
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);
}
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);
}
Aggregations