use of core.srs.Rotate in project solution-finder by knewjade.
the class DeepdropCandidate method search.
@Override
public Set<Action> search(Field field, Piece piece, int appearY) {
HashSet<Action> actions = new HashSet<>();
for (Rotate rotate : Rotate.values()) {
Mino mino = minoFactory.create(piece, rotate);
for (int x = -mino.getMinX(); x < FIELD_WIDTH - mino.getMaxX(); x++) {
for (int y = appearY - mino.getMaxY() - 1; -mino.getMinY() <= y; y--) {
if (field.canPut(mino, x, y) && field.isOnGround(mino, x, y)) {
Action action = minoShifter.createTransformedAction(piece, rotate, x, y);
actions.add(action);
}
}
}
}
return actions;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class HarddropCandidate method search.
@Override
public // ハードドロップで置くことができ、appearY以下にミノがすべて収まる場所を列挙する
Set<Action> search(Field field, Piece piece, int appearY) {
HashSet<Action> actions = new HashSet<>();
for (Rotate rotate : minoShifter.getUniqueRotates(piece)) {
Mino mino = minoFactory.create(piece, rotate);
int y = appearY - mino.getMinY();
int maxY = appearY - mino.getMaxY();
for (int x = -mino.getMinX(); x < FIELD_WIDTH - mino.getMaxX(); x++) {
int harddropY = field.getYOnHarddrop(mino, x, y);
if (harddropY < maxY) {
Action action = minoShifter.createTransformedAction(piece, rotate, x, harddropY);
actions.add(action);
}
}
}
return actions;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class LockedCandidate method checkRightRotation.
private boolean checkRightRotation(Field field, Mino mino, int x, int y) {
Rotate currentRotate = mino.getRotate();
Mino minoBefore = minoFactory.create(mino.getPiece(), currentRotate.getLeftRotate());
// 右回転前のテストパターンを取得
int[][] patterns = minoRotation.getRightPatternsFrom(minoBefore);
for (int[] pattern : patterns) {
int fromX = x - pattern[0];
int fromY = y - pattern[1];
if (canPutMinoInField(field, minoBefore, fromX, fromY)) {
int[] kicks = minoRotation.getKicksWithRightRotation(field, minoBefore, mino, fromX, fromY);
if (kicks != null && pattern[0] == kicks[0] && pattern[1] == kicks[1]) {
if (check(field, minoBefore, fromX, fromY, From.None)) {
lockedCache.found(x, y, currentRotate);
return true;
}
}
}
}
return false;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class LockedCandidate method checkLeftRotation.
private boolean checkLeftRotation(Field field, Mino mino, int x, int y) {
Rotate currentRotate = mino.getRotate();
Mino minoBefore = minoFactory.create(mino.getPiece(), currentRotate.getRightRotate());
// 右回転前のテストパターンを取得
int[][] patterns = minoRotation.getLeftPatternsFrom(minoBefore);
for (int[] pattern : patterns) {
int fromX = x - pattern[0];
int fromY = y - pattern[1];
if (canPutMinoInField(field, minoBefore, fromX, fromY)) {
int[] kicks = minoRotation.getKicksWithLeftRotation(field, minoBefore, mino, fromX, fromY);
if (kicks != null && pattern[0] == kicks[0] && pattern[1] == kicks[1]) {
if (check(field, minoBefore, fromX, fromY, From.None)) {
lockedCache.found(x, y, currentRotate);
return true;
}
}
}
}
return false;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class HarddropReachable method checks.
@Override
public boolean checks(Field field, Mino mino, int x, int y, int appearY) {
assert field.canPut(mino, x, y);
this.appearY = appearY;
Piece piece = mino.getPiece();
Rotate rotate = mino.getRotate();
if (check(field, piece, x, y, rotate))
return true;
List<Action> actions = minoShifter.enumerateSameOtherActions(piece, rotate, x, y);
for (Action action : actions) if (check(field, piece, action.getX(), action.getY(), action.getRotate()))
return true;
return false;
}
Aggregations