use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckerNoHoldTest method testCaseFilledLine.
@Test
void testCaseFilledLine() throws Exception {
List<Pair<List<Piece>, Boolean>> testCases = new ArrayList<Pair<List<Piece>, Boolean>>() {
{
add(new Pair<>(Arrays.asList(I, Z, L, I), true));
}
};
// Field
String marks = "" + "XXXXX_____" + "XXXXXXXXXX" + "XXXXXX____" + "XXXXXXX___" + "XXXXXX____" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 5;
int maxDepth = 4;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
for (Pair<List<Piece>, Boolean> testCase : testCases) {
// Set test case
List<Piece> pieces = testCase.getKey();
Boolean expectedCount = testCase.getValue();
// Execute
boolean isSucceed = checker.check(field, pieces, candidate, maxClearLine, maxDepth);
assertThat(isSucceed).isEqualTo(expectedCount);
// Check result
if (isSucceed)
assertResult(field, maxClearLine, reachable, pieces);
}
}
use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckerNoHoldTest method testCase1.
@Test
void testCase1() throws Exception {
List<Pair<List<Piece>, Boolean>> testCases = new ArrayList<Pair<List<Piece>, Boolean>>() {
{
add(new Pair<>(Arrays.asList(J, I, O, L, S, Z, T), true));
add(new Pair<>(Arrays.asList(J, O, I, L, Z, S, T), true));
add(new Pair<>(Arrays.asList(O, J, I, L, Z, S, T), true));
}
};
// Field
String marks = "" + "X________X" + "X________X" + "XX______XX" + "XXXXXX__XX" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 4;
int maxDepth = 6;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
for (Pair<List<Piece>, Boolean> testCase : testCases) {
// Set test case
List<Piece> pieces = testCase.getKey();
Boolean expectedCount = testCase.getValue();
// Execute
boolean isSucceed = checker.check(field, pieces, candidate, maxClearLine, maxDepth);
assertThat(isSucceed).isEqualTo(expectedCount);
// Check result
if (isSucceed)
assertResult(field, maxClearLine, reachable, pieces);
}
}
use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckerNoHoldTest method testCase2.
@Test
void testCase2() throws Exception {
List<Pair<List<Piece>, Boolean>> testCases = new ArrayList<Pair<List<Piece>, Boolean>>() {
{
add(new Pair<>(Arrays.asList(I, L, T, S, Z), true));
}
};
// Field
String marks = "" + "XX______XX" + "X______XXX" + "X______XXX" + "XX_XXX_XXX" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 4;
int maxDepth = 5;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
for (Pair<List<Piece>, Boolean> testCase : testCases) {
// Set test case
List<Piece> pieces = testCase.getKey();
Boolean expectedCount = testCase.getValue();
// Execute
boolean isSucceed = checker.check(field, pieces, candidate, maxClearLine, maxDepth);
assertThat(isSucceed).isEqualTo(expectedCount);
// Check result
if (isSucceed)
assertResult(field, maxClearLine, reachable, pieces);
}
}
use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckerUsingHoldTest method testNoPossiblePerfect.
@ParameterizedTest
@ArgumentsSource(TestCase.class)
@LongTest
void testNoPossiblePerfect(LongPieces pieces) throws Exception {
// Field
Field field = FieldFactory.createSmallField();
int maxClearLine = 4;
int maxDepth = 10;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
// Set test case
List<Piece> blocks = pieces.getPieces();
// Execute
boolean isSucceed = checker.check(field, blocks, candidate, maxClearLine, maxDepth);
assertThat(isSucceed).isFalse();
// Check result
if (isSucceed)
assertResult(field, maxClearLine, reachable, blocks);
}
use of core.action.reachable.LockedReachable in project solution-finder by knewjade.
the class CheckmateNoHoldTest method testMultiPath2.
@Test
void testMultiPath2() throws Exception {
// Field
String marks = "" + "X____XXXXX" + "XX__XXXXXX" + "XX__XXXXXX" + "XXXXXX__XX" + "XXXXXX__XX" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 5;
int maxDepth = 3;
// Initialize
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
LockedReachable reachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxClearLine);
// Assertion
// Set test case
List<Piece> pieces = Arrays.asList(S, Z, O);
int expectedCount = 1;
// 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);
}
Aggregations