Search in sources :

Example 6 with Pair

use of common.datastore.Pair in project solution-finder by knewjade.

the class SingleCheckerUsingHoldInvoker method search.

@Override
public List<Pair<Pieces, Boolean>> search(Field field, List<Pieces> searchingPieces, int maxClearLine, int maxDepth) throws FinderExecuteException {
    ConcurrentVisitedTree visitedTree = new ConcurrentVisitedTree();
    Obj obj = new Obj(field, maxClearLine, maxDepth, visitedTree);
    ArrayList<Pair<Pieces, Boolean>> results = new ArrayList<>();
    try {
        for (Pieces target : searchingPieces) {
            Task task = new Task(obj, commonObj, target);
            Pair<Pieces, Boolean> call = task.call();
            results.add(call);
        }
    } catch (Exception e) {
        throw new FinderExecuteException(e);
    }
    // 結果をリストに追加する
    return results;
}
Also used : CheckerCommonObj(concurrent.checker.invoker.CheckerCommonObj) ArrayList(java.util.ArrayList) FinderExecuteException(exceptions.FinderExecuteException) ConcurrentVisitedTree(common.tree.ConcurrentVisitedTree) ExecutionException(java.util.concurrent.ExecutionException) FinderExecuteException(exceptions.FinderExecuteException) Pair(common.datastore.Pair) Pieces(common.datastore.blocks.Pieces)

Example 7 with Pair

use of common.datastore.Pair in project solution-finder by knewjade.

the class LinkPathOutput method createALink.

private Pair<String, Integer> createALink(PathPair pathPair) {
    // パターンを表す名前 を生成
    String linkText = pathPair.getSampleOperations().stream().map(operationWithKey -> operationWithKey.getPiece().getName() + "-" + operationWithKey.getRotate().name()).collect(Collectors.joining(" "));
    // テト譜に変換
    String encode = pathPair.getFumen();
    // 有効なミノ順をまとめる
    AtomicInteger counter = new AtomicInteger();
    String validOrders = pathPair.blocksStreamForValidSolution().map(longBlocks -> longBlocks.blockStream().map(Piece::getName).collect(Collectors.joining())).peek(s -> counter.incrementAndGet()).collect(Collectors.joining(", "));
    // 出力
    return new Pair<>(String.format("<a href='http://fumen.zui.jp/?v115@%s' target='_blank'>%s</a> [%s]", encode, linkText, validOrders), counter.get());
}
Also used : Piece(core.mino.Piece) Arrays(java.util.Arrays) ColorType(common.tetfu.common.ColorType) entry.path(entry.path) BufferedWriter(java.io.BufferedWriter) Pair(common.datastore.Pair) LongPieces(common.datastore.blocks.LongPieces) FinderExecuteException(exceptions.FinderExecuteException) FinderInitializeException(exceptions.FinderInitializeException) Collectors(java.util.stream.Collectors) File(java.io.File) SizedBit(searcher.pack.SizedBit) List(java.util.List) Field(core.field.Field) ColoredFieldFactory(common.tetfu.field.ColoredFieldFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HTMLBuilder(output.HTMLBuilder) Comparator(java.util.Comparator) HTMLColumn(output.HTMLColumn) ColoredField(common.tetfu.field.ColoredField) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Piece(core.mino.Piece) Pair(common.datastore.Pair)

Example 8 with Pair

use of common.datastore.Pair in project solution-finder by knewjade.

the class CheckerNoHoldInvokerTest method runTestCase.

private AnalyzeTree runTestCase(ConcurrentCheckerInvoker invoker, Field field, List<Pieces> searchingPieces, int maxClearLine, int maxDepth) throws FinderExecuteException {
    List<Pair<Pieces, Boolean>> resultPairs = invoker.search(field, searchingPieces, maxClearLine, maxDepth);
    // 結果を集計する
    AnalyzeTree tree = new AnalyzeTree();
    for (Pair<Pieces, Boolean> resultPair : resultPairs) {
        Pieces pieces = resultPair.getKey();
        Boolean result = resultPair.getValue();
        tree.set(result, pieces);
    }
    System.out.println(tree.show());
    return tree;
}
Also used : Pair(common.datastore.Pair) AnalyzeTree(common.tree.AnalyzeTree) Pieces(common.datastore.blocks.Pieces)

Aggregations

Pair (common.datastore.Pair)8 Pieces (common.datastore.blocks.Pieces)6 AnalyzeTree (common.tree.AnalyzeTree)4 Field (core.field.Field)4 FinderExecuteException (exceptions.FinderExecuteException)3 ArrayList (java.util.ArrayList)3 Action (common.datastore.action.Action)2 LongPieces (common.datastore.blocks.LongPieces)2 PatternGenerator (common.pattern.PatternGenerator)2 ConcurrentVisitedTree (common.tree.ConcurrentVisitedTree)2 CheckerCommonObj (concurrent.checker.invoker.CheckerCommonObj)2 MinoFactory (core.mino.MinoFactory)2 Piece (core.mino.Piece)2 List (java.util.List)2 ExecutorService (java.util.concurrent.ExecutorService)2 Injector (com.google.inject.Injector)1 Result (common.datastore.Result)1 ReadOnlyListPieces (common.datastore.blocks.ReadOnlyListPieces)1 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)1 ColorType (common.tetfu.common.ColorType)1