use of core.mino.MinoFactory in project solution-finder by knewjade.
the class TetfuTest method decode8.
@Test
void decode8() throws Exception {
String value = "bhD8hlD8JeAgHbhD8h0D8JeAAA";
MinoFactory factory = new MinoFactory();
ColorConverter converter = new ColorConverter();
Tetfu tetfu = new Tetfu(factory, converter);
List<TetfuPage> pages = tetfu.decode(value);
assertThat(pages).hasSize(2);
assertThat(pages.get(0)).returns(ColorType.Empty, TetfuPage::getColorType);
assertThat(pages.get(1)).returns(ColorType.Empty, TetfuPage::getColorType);
assertField(ColoredFieldFactory.createColoredField("XXXXJJXXXX"), pages.get(1).getField());
}
use of core.mino.MinoFactory in project solution-finder by knewjade.
the class DevRandomEntryPoint method run.
@Override
public void run() throws FinderException {
PatternGenerator generator = createBlockGenerator(pattern);
List<Pieces> blocks = generator.blocksStream().collect(Collectors.toList());
int index = new Random().nextInt(blocks.size());
Pieces selected = blocks.get(index);
String quiz = Tetfu.encodeForQuiz(selected.getPieces());
MinoFactory minoFactory = new MinoFactory();
ColorConverter converter = new ColorConverter();
ColoredField coloredField = getTetfu(minoFactory, converter);
Tetfu tetfu = new Tetfu(minoFactory, converter);
TetfuElement element = new TetfuElement(coloredField, quiz);
String encode = tetfu.encode(Collections.singletonList(element));
System.out.println("v115@" + encode);
}
use of core.mino.MinoFactory in project solution-finder by knewjade.
the class MoveEntryPoint method run.
@Override
public void run() throws FinderException {
output("# Setup Field");
// Setup field
Field field = settings.getField();
Verify.field(field);
int maxClearLine = settings.getMaxClearLine();
output(FieldView.toString(field, maxClearLine));
// Setup max depth
// パフェに必要なミノ数
int maxDepth = Verify.maxDepth(field, maxClearLine);
output();
// ========================================
output("Searching patterns:");
// Setup patterns
List<String> patterns = settings.getPatterns();
PatternGenerator generator = Verify.patterns(patterns);
// Output patterns
for (String pattern : patterns) output(" " + pattern);
output();
// ========================================
// baseファイル
MyFile base = new MyFile(settings.getOutputBaseFilePath());
base.mkdirs();
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
ColorConverter colorConverter = new ColorConverter();
PerfectValidator perfectValidator = new PerfectValidator();
PutterNoHold<Action> putter = new PutterNoHold<>(minoFactory, perfectValidator);
output("# Calculate");
try (BufferedWriter bw = base.newBufferedWriter()) {
List<Pieces> pieces = generator.blocksStream().collect(Collectors.toList());
for (Pieces piece : pieces) {
String using = piece.blockStream().map(Piece::getName).collect(Collectors.joining());
output(" -> " + using);
TreeSet<Order> first = putter.first(field, piece.getPieceArray(), new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine), maxClearLine, maxDepth);
for (Order order : first) {
Stream<Operation> operationStream = order.getHistory().getOperationStream();
List<MinoOperationWithKey> operationWithKeys = OperationTransform.parseToOperationWithKeys(field, new Operations(operationStream), minoFactory, maxClearLine);
BlockField blockField = OperationTransform.parseToBlockField(operationWithKeys, minoFactory, maxClearLine);
String encodeColor = encodeColor(field, minoFactory, colorConverter, blockField);
String encodeGray = encodeGray(order.getField(), minoFactory, colorConverter);
bw.write(String.format("%s,%s,%s", using, encodeColor, encodeGray));
bw.newLine();
}
}
bw.flush();
} catch (IOException e) {
throw new FinderExecuteException("Failed to output file", e);
}
}
use of core.mino.MinoFactory in project solution-finder by knewjade.
the class MinoFieldComparatorTest method createSeparableMinos.
private SeparableMinos createSeparableMinos() {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
SizedBit sizedBit = new SizedBit(3, 4);
return SeparableMinos.createSeparableMinos(minoFactory, minoShifter, sizedBit);
}
use of core.mino.MinoFactory in project solution-finder by knewjade.
the class AllSeparableMinoFactoryTest method create3x3.
@Test
void create3x3() throws Exception {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
int width = 3;
int height = 3;
Set<SeparableMino> minos = getSeparableMinos(minoFactory, minoShifter, width, height);
assertThat(minos.stream()).hasSize(114);
assertThat(minos.stream().filter(createBlockPredicate(Piece.T))).hasSize(24);
assertThat(minos.stream().filter(createBlockPredicate(Piece.I))).hasSize(9);
assertThat(minos.stream().filter(createBlockPredicate(Piece.S))).hasSize(12);
assertThat(minos.stream().filter(createBlockPredicate(Piece.Z))).hasSize(12);
assertThat(minos.stream().filter(createBlockPredicate(Piece.O))).hasSize(9);
assertThat(minos.stream().filter(createBlockPredicate(Piece.L))).hasSize(24);
assertThat(minos.stream().filter(createBlockPredicate(Piece.J))).hasSize(24);
}
Aggregations