use of core.srs.MinoRotation in project solution-finder by knewjade.
the class LimitIterationCandidateTest method testSearch3When4Iteration.
@Test
void testSearch3When4Iteration() throws Exception {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
Candidate<Action> candidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 4);
String marks = "" + "XXXX______" + "XX_XXXXX__" + "X___X_____" + "XX_X______";
Field field = FieldFactory.createField(marks);
Set<Action> actions = candidate.search(field, Piece.T, 4);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Spawn)).hasSize(3).contains(MinimalAction.create(8, 0, Rotate.Spawn)).contains(MinimalAction.create(7, 0, Rotate.Spawn)).contains(MinimalAction.create(6, 0, Rotate.Spawn)).doesNotContain(MinimalAction.create(5, 0, Rotate.Spawn));
}
use of core.srs.MinoRotation in project solution-finder by knewjade.
the class LimitIterationCandidateTest method testSearch1.
@Test
void testSearch1() throws Exception {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
Candidate<Action> candidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 3);
String marks = "" + "__________" + "__________" + "____X_____";
Field field = FieldFactory.createField(marks);
Set<Action> actions = candidate.search(field, Piece.T, 4);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Spawn)).hasSize(8);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Right)).hasSize(9);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Reverse)).hasSize(8);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Left)).hasSize(9);
}
use of core.srs.MinoRotation in project solution-finder by knewjade.
the class LimitIterationCandidateTest method testSearch4.
@Test
void testSearch4() throws Exception {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
Candidate<Action> candidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 4);
String marks = "" + "XXXXX__XXX" + "XXXXX___XX" + "XXXX___XXX" + "";
Field field = FieldFactory.createField(marks);
Set<Action> actions = candidate.search(field, Piece.T, 3);
assertThat(actions).hasSize(5).contains(MinimalAction.create(6, 1, Rotate.Spawn)).contains(MinimalAction.create(5, 1, Rotate.Right)).contains(MinimalAction.create(6, 1, Rotate.Right)).contains(MinimalAction.create(6, 1, Rotate.Left)).contains(MinimalAction.create(6, 1, Rotate.Reverse));
}
use of core.srs.MinoRotation in project solution-finder by knewjade.
the class LimitIterationCandidateTest method testRandomHarddrop.
@Test
void testRandomHarddrop() {
Randoms randoms = new Randoms();
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
HarddropCandidate harddropCandidate = new HarddropCandidate(minoFactory, minoShifter);
LimitIterationCandidate limitIterationCandidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 0);
for (int count = 0; count < 10000; count++) {
int randomHeight = randoms.nextIntClosed(2, 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();
Set<Action> actions1 = harddropCandidate.search(field, piece, height);
Set<Action> actions2 = limitIterationCandidate.search(field, piece, height);
assertThat(actions2).isEqualTo(actions1);
}
}
use of core.srs.MinoRotation in project solution-finder by knewjade.
the class LockedCandidateTest method testSearch1.
@Test
void testSearch1() throws Exception {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = new MinoRotation();
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, 4);
String marks = "" + "__________" + "__________" + "____X_____";
Field field = FieldFactory.createField(marks);
Set<Action> actions = candidate.search(field, Piece.T, 4);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Spawn)).hasSize(8);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Right)).hasSize(9);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Reverse)).hasSize(8);
assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Left)).hasSize(9);
}
Aggregations