use of core.mino.Mino in project solution-finder by knewjade.
the class PositionLimitParser method createT.
private List<PositionLimitedMino> createT(DeltaLimit delta) {
Mino spawn = minoFactory.create(Piece.T, Rotate.Spawn);
Mino reverse = minoFactory.create(Piece.T, Rotate.Reverse);
Mino left = minoFactory.create(Piece.T, Rotate.Left);
Mino right = minoFactory.create(Piece.T, Rotate.Right);
switch(delta) {
case OddUp:
return Arrays.asList(PositionLimitedMino.create(left, PositionLimit.OddX), PositionLimitedMino.create(right, PositionLimit.OddX));
case EvenUp:
return Arrays.asList(PositionLimitedMino.create(left, PositionLimit.EvenX), PositionLimitedMino.create(right, PositionLimit.EvenX));
case Flat:
return Arrays.asList(PositionLimitedMino.create(spawn, PositionLimit.OddX), PositionLimitedMino.create(spawn, PositionLimit.EvenX), PositionLimitedMino.create(reverse, PositionLimit.OddX), PositionLimitedMino.create(reverse, PositionLimit.EvenX));
}
throw new IllegalStateException("No reachable");
}
use of core.mino.Mino 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.mino.Mino 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.mino.Mino in project solution-finder by knewjade.
the class LimitIterationCandidate method checkRightRotation.
private boolean checkRightRotation(Field field, Mino mino, int x, int y, int iteration) {
Mino minoBefore = minoFactory.create(mino.getPiece(), mino.getRotate().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, iteration + 1))
return true;
}
}
return false;
}
use of core.mino.Mino 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;
}
Aggregations