use of module.LongTest in project solution-finder by knewjade.
the class CheckmateNoHoldTest method testLong10.
@Test
@LongTest
void testLong10() throws Exception {
List<Pair<List<Piece>, Integer>> testCases = new ArrayList<Pair<List<Piece>, Integer>>() {
{
add(new Pair<>(Arrays.asList(I, S, Z, T, J, I, S, Z, S, Z, T), 3));
add(new Pair<>(Arrays.asList(S, Z, T, L, J, I, O, S, Z, T, L), 6));
add(new Pair<>(Arrays.asList(T, L, J, Z, S, O, O, T, J, L, I), 21));
add(new Pair<>(Arrays.asList(T, L, J, Z, S, O, O, T, J, L, T), 21));
add(new Pair<>(Arrays.asList(T, L, J, Z, S, O, O, T, J, L), 21));
add(new Pair<>(Arrays.asList(I, S, Z, T, J, I, S, Z, S, Z), 3));
add(new Pair<>(Arrays.asList(T, S, L, I, Z, J, L, O, O, S), 2));
add(new Pair<>(Arrays.asList(L, Z, S, J, Z, Z, Z, I, T, T), 7));
add(new Pair<>(Arrays.asList(T, T, S, S, Z, Z, L, L, J, J), 18));
add(new Pair<>(Arrays.asList(O, S, O, S, Z, L, Z, L, I, I), 4));
add(new Pair<>(Arrays.asList(J, I, T, O, L, S, I, T, Z, O), 9));
add(new Pair<>(Arrays.asList(S, T, J, L, O, O, T, S, L, L), 16));
}
};
// Field
int maxClearLine = 4;
int maxDepth = 10;
Field field = FieldFactory.createField(maxClearLine);
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
for (Pair<List<Piece>, Integer> testCase : testCases) {
// Set test case
List<Piece> pieces = testCase.getKey();
int expectedCount = testCase.getValue();
// Execute
List<Result> results = checkmate.search(field, pieces, candidate, maxClearLine, maxDepth);
assertThat(results).as(pieces.toString()).hasSize(expectedCount);
// Check result
for (Result result : results) assertResult(result, field, maxClearLine, reachable, pieces);
}
}
use of module.LongTest in project solution-finder by knewjade.
the class CheckmateUsingHoldReuseTest method randomCheckmateWithJustBlock.
@Test
@LongTest
void randomCheckmateWithJustBlock() {
Randoms randoms = new Randoms();
for (int count = 0; count < 25; count++) {
int maxClearLine = randoms.nextInt(3, 8);
int maxDepth = randoms.nextIntClosed(5, 7);
List<Piece> pieces = randoms.blocks(maxDepth);
Field field = randoms.field(maxClearLine, maxDepth);
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
Stopwatch stopwatchNoUse = Stopwatch.createStoppedStopwatch();
Stopwatch stopwatchReuse = Stopwatch.createStoppedStopwatch();
for (int swap = 0; swap < 250; swap++) {
int index = randoms.nextInt(3, pieces.size());
Piece pop = pieces.remove(index);
pieces.add(pop);
stopwatchNoUse.start();
List<Result> result1 = checkmate.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchNoUse.stop();
stopwatchReuse.start();
List<Result> result2 = checkmateReuse.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchReuse.stop();
assertThat(result2).hasSameSizeAs(result1).containsAll(result1);
}
// TODO:
// assertThat(stopwatchReuse.getNanoAverageTime()).isLessThan(stopwatchNoUse.getNanoAverageTime());
}
}
use of module.LongTest in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedOnDemandTest method testAllSRSValidPacksHeight4.
// 高さ4: パリティベースとの探索結果を比較する (同一ミノは2つまで)
@Test
@LongTest
void testAllSRSValidPacksHeight4() throws Exception {
int width = 3;
int height = 4;
String resultPath = ClassLoader.getSystemResource("perfects/pack_height4.txt").getPath();
List<TestData> testCases = Files.lines(Paths.get(resultPath)).map(line -> line.split("//")[0]).map(String::trim).filter(line -> !line.isEmpty()).map(line -> line.split("=")).map(split -> {
Stream<Piece> blocks = BlockInterpreter.parse(split[0]);
LongPieces pieces = new LongPieces(blocks);
int count = Integer.valueOf(split[1]);
return new TestData(pieces, count);
}).collect(Collectors.toList());
compareCount(width, height, testCases);
}
use of module.LongTest in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedOnDemandTest method testAllSRSValidPacksHeight6.
// 高さ6: パリティベースとの探索結果を比較する (同一ミノは2つまで)
@Test
@LongTest
void testAllSRSValidPacksHeight6() throws Exception {
int width = 2;
int height = 6;
String resultPath = ClassLoader.getSystemResource("perfects/pack_height6.txt").getPath();
List<TestData> testCases = Files.lines(Paths.get(resultPath)).map(line -> line.split("//")[0]).map(String::trim).filter(line -> !line.isEmpty()).map(line -> line.split("=")).map(split -> {
Stream<Piece> blocks = BlockInterpreter.parse(split[0]);
LongPieces pieces = new LongPieces(blocks);
int count = Integer.valueOf(split[1]);
return new TestData(pieces, count);
}).collect(Collectors.toList());
compareCount(width, height, testCases);
}
use of module.LongTest in project solution-finder by knewjade.
the class LimitIterationCandidateTest method testRandomLocked.
@Disabled
@Test
@LongTest
// TODO: mesure time, 移動回数をチェックしていないためテストに失敗することがある
void testRandomLocked() {
Randoms randoms = new Randoms();
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
LimitIterationCandidate limitIterationCandidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 12);
for (int count = 0; count < 10; count++) {
int randomHeight = randoms.nextIntClosed(10, 12);
int numOfMinos = randoms.nextIntClosed(4, randomHeight * 10 / 4 - 1);
Field field = randoms.field(randomHeight, numOfMinos);
int clearLine = field.clearLine();
int height = randomHeight - clearLine;
Piece piece = randoms.block();
String description = FieldView.toString(field, height) + piece;
Set<Action> actions1 = limitIterationCandidate.search(field, piece, height);
LockedCandidate lockedCandidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, height);
Set<Action> actions2 = lockedCandidate.search(field, piece, height);
assertThat(actions2).as(description).isEqualTo(actions1);
}
}
Aggregations