Search in sources :

Example 41 with MinoRotation

use of core.srs.MinoRotation in project solution-finder by knewjade.

the class LockedNeighborReachableTest method createLockedReachable.

private LockedReachable createLockedReachable(Injector injector, int maxClearLine) {
    MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
    MinoShifter minoShifter = injector.getInstance(MinoShifter.class);
    MinoRotation minoRotation = injector.getInstance(MinoRotation.class);
    return new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
}
Also used : MinoRotation(core.srs.MinoRotation) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter)

Example 42 with MinoRotation

use of core.srs.MinoRotation in project solution-finder by knewjade.

the class LockedReachableTest method createLockedReachable.

private LockedReachable createLockedReachable() {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new PassedMinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    return new LockedReachable(minoFactory, minoShifter, minoRotation, 8);
}
Also used : MinoRotation(core.srs.MinoRotation)

Example 43 with MinoRotation

use of core.srs.MinoRotation 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);
    }
}
Also used : Action(common.datastore.action.Action) MyFile(entry.path.output.MyFile) Operation(common.datastore.Operation) BufferedWriter(java.io.BufferedWriter) BlockField(common.datastore.BlockField) Field(core.field.Field) ColoredField(common.tetfu.field.ColoredField) LockedCandidate(core.action.candidate.LockedCandidate) MinoOperationWithKey(common.datastore.MinoOperationWithKey) BlockField(common.datastore.BlockField) ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) PutterNoHold(searcher.PutterNoHold) PerfectValidator(searcher.common.validator.PerfectValidator) Operations(common.datastore.Operations) Pieces(common.datastore.blocks.Pieces) Order(common.datastore.order.Order) PatternGenerator(common.pattern.PatternGenerator) IOException(java.io.IOException) EntryPoint(entry.EntryPoint) MinoRotation(core.srs.MinoRotation) MinoShifter(core.mino.MinoShifter) FinderExecuteException(exceptions.FinderExecuteException)

Example 44 with MinoRotation

use of core.srs.MinoRotation in project solution-finder by knewjade.

the class NeighborsTest method createNeighbors.

private Neighbors createNeighbors(Injector injector) {
    MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
    MinoRotation minoRotation = injector.getInstance(MinoRotation.class);
    OriginalPieceFactory pieceFactory = injector.getInstance(OriginalPieceFactory.class);
    return new Neighbors(minoFactory, minoRotation, pieceFactory);
}
Also used : MinoRotation(core.srs.MinoRotation) MinoFactory(core.mino.MinoFactory)

Aggregations

MinoRotation (core.srs.MinoRotation)44 MinoFactory (core.mino.MinoFactory)38 Field (core.field.Field)37 MinoShifter (core.mino.MinoShifter)37 Test (org.junit.jupiter.api.Test)32 LongTest (module.LongTest)29 Action (common.datastore.action.Action)25 Piece (core.mino.Piece)17 LockedReachable (core.action.reachable.LockedReachable)16 ColumnField (core.column_field.ColumnField)16 InOutPairField (searcher.pack.InOutPairField)16 Randoms (lib.Randoms)15 LockedCandidate (core.action.candidate.LockedCandidate)14 MinimalAction (common.datastore.action.MinimalAction)12 PermutationIterable (common.iterable.PermutationIterable)12 List (java.util.List)10 PerfectValidator (searcher.common.validator.PerfectValidator)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)8 FieldFactory (core.field.FieldFactory)8