use of common.parser.BlockInterpreter in project solution-finder by knewjade.
the class CheckerUsingHoldTest method testPossiblePerfect.
@Test
@LongTest
void testPossiblePerfect() throws Exception {
// Field
Field field = FieldFactory.createSmallField();
int maxClearLine = 4;
int maxDepth = 10;
// Set to check No Possible Perfect
String noPerfectPath = ClassLoader.getSystemResource("orders/noperfect.txt").getPath();
HashSet<LongPieces> noPerfectSet = Files.lines(Paths.get(noPerfectPath)).map(BlockInterpreter::parse).map(LongPieces::new).collect(Collectors.toCollection(HashSet::new));
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
Randoms randoms = new Randoms();
for (int count = 0; count < 100; count++) {
// Set test case
int cycle = randoms.nextIntClosed(0, 8);
List<Piece> pieces = randoms.block11InCycle(cycle);
// Execute
boolean isSucceed = checker.check(field, pieces, candidate, maxClearLine, maxDepth);
boolean expectedFlag = !noPerfectSet.contains(new LongPieces(pieces));
assertThat(isSucceed).isEqualTo(expectedFlag);
// Check result
if (isSucceed)
assertResult(field, maxClearLine, reachable, pieces);
}
}
Aggregations