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