use of core.mino.Mino in project solution-finder by knewjade.
the class OneFumenParser method createBlockField.
private BlockField createBlockField(List<MinoOperationWithKey> operations, int maxClearLine) {
BlockField blockField = new BlockField(maxClearLine);
for (MinoOperationWithKey key : operations) {
Field test = createField(key, maxClearLine);
Mino mino = key.getMino();
blockField.merge(test, mino.getPiece());
}
return blockField;
}
use of core.mino.Mino in project solution-finder by knewjade.
the class LimitIterationCandidate method search.
@Override
public Set<Action> search(Field field, Piece piece, int appearY) {
// temporaryの初期化
this.appearY = 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)) {
if (check(field, mino, x, y, From.None, 0)) {
Action action = minoShifter.createTransformedAction(piece, rotate, x, y);
actions.add(action);
}
}
}
}
}
return actions;
}
use of core.mino.Mino in project solution-finder by knewjade.
the class LimitIterationCandidate method checkLeftRotation.
private boolean checkLeftRotation(Field field, Mino mino, int x, int y, int iteration) {
Mino minoBefore = minoFactory.create(mino.getPiece(), mino.getRotate().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, iteration + 1))
return true;
}
}
return false;
}
use of core.mino.Mino in project solution-finder by knewjade.
the class LockedCandidate method search.
@Override
public Set<Action> search(Field field, Piece piece, int appearY) {
// temporaryの初期化
this.appearY = appearY;
lockedCache.clear();
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)) {
if (check(field, mino, x, y, From.None)) {
Action action = minoShifter.createTransformedAction(piece, rotate, x, y);
actions.add(action);
} else {
lockedCache.visit(x, y, rotate);
}
lockedCache.resetTrail();
}
}
}
}
return actions;
}
use of core.mino.Mino in project solution-finder by knewjade.
the class LockedNeighborCandidate method search.
@Override
public Set<Neighbor> search(Field field, Piece piece, int appearY) {
this.field = field;
HashSet<Neighbor> results = new HashSet<>();
cache.clear();
Set<Rotate> uniqueRotates = minoShifter.getUniqueRotates(piece);
for (Rotate rotate : uniqueRotates) {
Mino mino = minoFactory.create(piece, rotate);
for (int x = -mino.getMinX(); x < FIELD_WIDTH - mino.getMaxX(); x++) {
for (int y = -mino.getMinY(); y < appearY - mino.getMaxY(); y++) {
Neighbor neighbor = neighbors.get(piece, rotate, x, y);
if (field.canPut(neighbor.getPiece()) && field.isOnGround(mino, x, y)) {
loop(results, neighbor);
}
}
}
}
return results;
}
Aggregations