use of core.srs.Rotate in project solution-finder by knewjade.
the class DeepdropCandidateTest method testRandom.
@Test
void testRandom() throws Exception {
Randoms randoms = new Randoms();
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new PassedMinoShifter();
DeepdropCandidate candidate = new DeepdropCandidate(minoFactory, minoShifter);
for (int count = 0; count < 10000; count++) {
int height = randoms.nextIntClosed(2, 12);
int numOfMinos = randoms.nextIntClosed(4, height * 10 / 4 - 1);
Field field = randoms.field(height, numOfMinos);
height -= field.clearLine();
Piece piece = randoms.block();
Set<Action> actions = candidate.search(field, piece, height);
for (Rotate rotate : Rotate.values()) {
Coordinates.walk(minoFactory.create(piece, rotate), height).map(coordinate -> MinimalAction.create(coordinate.x, coordinate.y, rotate)).forEach(action -> {
int x = action.getX();
int y = action.getY();
Mino mino = minoFactory.create(piece, action.getRotate());
if (actions.contains(action)) {
// おける
assertThat(field.canPut(mino, x, y)).isTrue();
assertThat(field.isOnGround(mino, x, y)).isTrue();
} else {
// おけない
assertThat(field.canPut(mino, x, y) && field.isOnGround(mino, x, y)).isFalse();
}
});
}
}
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class LockedCacheTest method assertCache.
private void assertCache(int height) {
LockedCache cache = new LockedCache(height);
for (int y = 0; y < height; y++) {
for (int x = 0; x < 10; x++) {
for (Rotate rotate : Rotate.values()) {
assertThat(cache.isVisit(x, y, rotate)).isFalse();
cache.visit(x, y, rotate);
assertThat(cache.isVisit(x, y, rotate)).isTrue();
assertThat(cache.isFound(x, y, rotate)).isFalse();
cache.found(x, y, rotate);
assertThat(cache.isFound(x, y, rotate)).isTrue();
}
}
}
cache.clear();
for (int y = 0; y < height; y++) {
for (int x = 0; x < 10; x++) {
for (Rotate rotate : Rotate.values()) {
assertThat(cache.isVisit(x, y, rotate)).isFalse();
assertThat(cache.isFound(x, y, rotate)).isFalse();
}
}
}
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class PassedMinoShifterTest method enumerateSameOtherActions.
@Test
void enumerateSameOtherActions() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int x = randoms.nextInt(10);
int y = randoms.nextInt(0, 12);
List<Action> actions = minoShifter.enumerateSameOtherActions(piece, rotate, x, y);
assertThat(actions).isEmpty();
}
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class PassedMinoShifterTest method createTransformedAction.
@Test
void createTransformedAction() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int x = randoms.nextInt(10);
int y = randoms.nextInt(0, 12);
MinimalAction action = MinimalAction.create(x, y, rotate);
Action actualAction = minoShifter.createTransformedAction(piece, action);
assertThat(actualAction).isEqualTo(action);
}
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class PassedMinoShifterTest method createTransformedRotate.
@Test
void createTransformedRotate() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
Rotate actualRotate = minoShifter.createTransformedRotate(piece, rotate);
assertThat(actualRotate).isEqualTo(rotate);
}
}
Aggregations