use of core.mino.Mino 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.mino.Mino in project solution-finder by knewjade.
the class LockedNeighborCandidate method loop.
private void loop(HashSet<Neighbor> results, Neighbor neighbor) {
cache.resetTrail();
if (check(neighbor)) {
results.add(neighbor);
} else {
OriginalPiece piece = neighbor.getPiece();
Mino mino = piece.getMino();
Piece block = mino.getPiece();
List<Action> actions = minoShifter.enumerateSameOtherActions(block, mino.getRotate(), piece.getX(), piece.getY());
for (Action action : actions) {
Neighbor similar = neighbors.get(block, action.getRotate(), action.getX(), action.getY());
if (check(similar))
results.add(similar);
}
}
}
use of core.mino.Mino in project solution-finder by knewjade.
the class HarddropReachable method check.
private boolean check(Field field, Piece piece, int x, int y, Rotate rotate) {
lockedCache.clear();
Mino mino = minoFactory.create(piece, rotate);
return check(field, mino, x, y);
}
use of core.mino.Mino in project solution-finder by knewjade.
the class LockedReachable 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))
return true;
}
}
return false;
}
use of core.mino.Mino in project solution-finder by knewjade.
the class OperationTransform method parseToOperations.
// List<Operation>に変換する。正しく組み立てられるかはチェックしない
// operationWithKeysは組み立てられる順番に並んでいること
public static Operations parseToOperations(Field fieldOrigin, List<MinoOperationWithKey> operationWithKeys, int height) {
ArrayList<Operation> operations = new ArrayList<>();
Field field = fieldOrigin.freeze(height);
for (MinoOperationWithKey operationWithKey : operationWithKeys) {
long deleteKey = field.clearLineReturnKey();
// すでに下のラインが消えているときは、その分スライドさせる
int originalY = operationWithKey.getY();
int deletedLines = Long.bitCount(KeyOperators.getMaskForKeyBelowY(originalY) & deleteKey);
Mino mino = operationWithKey.getMino();
int x = operationWithKey.getX();
int y = originalY - deletedLines;
operations.add(new SimpleOperation(mino.getPiece(), mino.getRotate(), x, y));
field.put(mino, x, y);
field.insertBlackLineWithKey(deleteKey);
}
return new Operations(operations);
}
Aggregations