use of searcher.pack.SizedBit in project solution-finder by knewjade.
the class MappedBasicSolutionsFactoryTest method create3x3.
@Test
void create3x3() throws Exception {
SizedBit sizedBit = new SizedBit(3, 3);
int expectedSolutions = 254;
int expectedSolutionItems = 3972;
assertCache(sizedBit, expectedSolutions, expectedSolutionItems);
}
use of searcher.pack.SizedBit in project solution-finder by knewjade.
the class MappedBasicSolutionsFactoryTest method create3x4.
@Test
void create3x4() throws Exception {
SizedBit sizedBit = new SizedBit(3, 4);
int expectedSolutions = 2211;
int expectedSolutionItems = 228022;
assertCache(sizedBit, expectedSolutions, expectedSolutionItems);
}
use of searcher.pack.SizedBit in project solution-finder by knewjade.
the class MappedBasicSolutionsFactoryTest method create3x1.
@Test
void create3x1() throws Exception {
SizedBit sizedBit = new SizedBit(3, 1);
int expectedSolutions = 3;
int expectedSolutionItems = 3;
assertCache(sizedBit, expectedSolutions, expectedSolutionItems);
}
use of searcher.pack.SizedBit in project solution-finder by knewjade.
the class MappedBasicSolutionsFactoryTest method create2x6.
@Test
@LongTest
void create2x6() throws Exception {
SizedBit sizedBit = new SizedBit(2, 6);
int expectedSolutions = 3490;
int expectedSolutionItems = 8380826;
assertCache(sizedBit, expectedSolutions, expectedSolutionItems);
}
use of searcher.pack.SizedBit in project solution-finder by knewjade.
the class PatternCSVPathOutput method output.
@Override
public void output(List<PathPair> pathPairs, Field field, SizedBit sizedBit) throws FinderExecuteException {
this.lastException = null;
outputLog("Found path = " + pathPairs.size());
AtomicInteger validCounter = new AtomicInteger();
AtomicInteger allCounter = new AtomicInteger();
try (AsyncBufferedFileWriter writer = outputBaseFile.newAsyncWriter()) {
writer.writeAndNewLine("ツモ,対応地形数,使用ミノ,未使用ミノ,テト譜");
generator.blocksStream().parallel().map(blocks -> {
// シーケンス名を取得
String sequenceName = blocks.blockStream().map(Piece::getName).collect(Collectors.joining());
// パフェ可能な地形を抽出
List<PathPair> valid = pathPairs.stream().filter(pathPair -> {
HashSet<? extends Pieces> buildBlocks = pathPair.blocksHashSetForPattern();
return buildBlocks.contains(blocks);
}).collect(Collectors.toList());
// パフェ可能な地形数
int possibleSize = valid.size();
// パフェ可能ならカウンターをインクリメント
allCounter.incrementAndGet();
if (0 < possibleSize)
validCounter.incrementAndGet();
// パフェ可能な地形のテト譜を連結
String fumens = valid.stream().sorted(Comparator.comparing(PathPair::getPatternSize).reversed()).map(pathPair -> "v115@" + pathPair.getFumen()).collect(Collectors.joining(";"));
// 使うミノ一覧を抽出
Set<PieceCounter> usesSet = valid.stream().map(PathPair::getBlockCounter).collect(Collectors.toSet());
String uses = usesSet.stream().map(blockCounter -> {
return blockCounter.getBlockStream().sorted().map(Piece::getName).collect(Collectors.joining());
}).collect(Collectors.joining(";"));
// 残せるミノ一覧を抽出
PieceCounter orderPieceCounter = new PieceCounter(blocks.blockStream());
String noUses = usesSet.stream().map(orderPieceCounter::removeAndReturnNew).distinct().map(blockCounter -> {
return blockCounter.getBlockStream().sorted().map(Piece::getName).collect(Collectors.joining());
}).collect(Collectors.joining(";"));
return String.format("%s,%d,%s,%s,%s", sequenceName, possibleSize, uses, noUses, fumens);
}).forEach(writer::writeAndNewLine);
writer.flush();
} catch (IOException e) {
throw new FinderExecuteException("Failed to output file", e);
}
outputLog("");
outputLog("perfect clear percent");
outputLog(String.format(" -> success = %.2f%% (%d/%d)", 100.0 * validCounter.get() / allCounter.get(), validCounter.get(), allCounter.get()));
if (lastException != null)
throw new FinderExecuteException("Error to output file", lastException);
}
Aggregations