use of core.action.candidate.LockedCandidate in project solution-finder by knewjade.
the class CheckerNoHoldCountTest method runTestCase.
private AnalyzeTree runTestCase(PatternGenerator blocksGenerator, int maxClearLine, int maxDepth, String marks) {
Field field = FieldFactory.createField(marks);
// Initialize
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
PerfectValidator validator = new PerfectValidator();
CheckerNoHold<Action> checker = new CheckerNoHold<>(minoFactory, validator);
// Measure
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
AnalyzeTree tree = new AnalyzeTree();
blocksGenerator.blocksStream().forEach(blocks -> {
List<Piece> pieceList = blocks.getPieces();
boolean result = checker.check(field, pieceList, candidate, maxClearLine, maxDepth);
tree.set(result, pieceList);
});
return tree;
}
use of core.action.candidate.LockedCandidate in project solution-finder by knewjade.
the class CheckerNoHoldTest method testCase3.
@Test
void testCase3() throws Exception {
List<Pair<List<Piece>, Boolean>> testCases = new ArrayList<Pair<List<Piece>, Boolean>>() {
{
add(new Pair<>(Arrays.asList(T, I, L, S, O, Z, J), false));
add(new Pair<>(Arrays.asList(O, J, I, L, T, S, Z), false));
add(new Pair<>(Arrays.asList(O, J, L, T, I, S, Z), true));
}
};
// Field
String marks = "" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXXXX__" + "XXXXXXXX__" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 8;
int maxDepth = 7;
// 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.candidate.LockedCandidate in project solution-finder by knewjade.
the class CheckerNoHoldTest method testGraceSystem.
@Test
void testGraceSystem() throws Exception {
List<Pair<List<Piece>, Boolean>> testCases = new ArrayList<Pair<List<Piece>, Boolean>>() {
{
add(new Pair<>(Arrays.asList(T, S, O, J), false));
add(new Pair<>(Arrays.asList(T, O, J, S), false));
add(new Pair<>(Arrays.asList(T, T, L, J), true));
add(new Pair<>(Arrays.asList(T, T, S, Z), true));
add(new Pair<>(Arrays.asList(T, S, Z, T), false));
add(new Pair<>(Arrays.asList(J, S, Z, L), false));
add(new Pair<>(Arrays.asList(Z, I, O, T), false));
add(new Pair<>(Arrays.asList(I, J, J, O), true));
add(new Pair<>(Arrays.asList(T, S, Z, J), false));
add(new Pair<>(Arrays.asList(L, S, Z, T), false));
}
};
// Field
String marks = "" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "XXXXXX____" + "";
Field field = FieldFactory.createField(marks);
int maxClearLine = 4;
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.candidate.LockedCandidate 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.candidate.LockedCandidate 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);
}
}
Aggregations