use of core.srs.Rotate 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.srs.Rotate in project solution-finder by knewjade.
the class OperationWithKeyInterpreter method parseToStream.
public static Stream<MinoOperationWithKey> parseToStream(String operations, MinoFactory minoFactory) {
return Arrays.stream(operations.split(";")).map(s -> s.split(",")).map(strings -> {
Piece piece = StringEnumTransform.toPiece(strings[0]);
Rotate rotate = StringEnumTransform.toRotate(strings[1]);
Mino mino = minoFactory.create(piece, rotate);
int x = Integer.valueOf(strings[2]);
int y = Integer.valueOf(strings[3]);
long deleteKey = Long.valueOf(strings[4]);
long usingKey = Long.valueOf(strings[5]);
return new FullOperationWithKey(mino, x, y, deleteKey, usingKey);
});
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class ActionEncoder method coordinate_to_int.
private int coordinate_to_int(TetfuElement element) {
int x = element.getX();
int y = element.getY();
ColorType type = element.getColorType();
Rotate rotate = element.getRotate();
if (!ColorType.isMinoBlock(type)) {
x = 0;
y = 22;
} else if (type == ColorType.O && rotate == Rotate.Left) {
x -= 1;
y -= 1;
} else if (type == ColorType.O && rotate == Rotate.Reverse)
x -= 1;
else if (type == ColorType.O && rotate == Rotate.Spawn)
y += 1;
else if (type == ColorType.I && rotate == Rotate.Reverse)
x -= 1;
else if (type == ColorType.I && rotate == Rotate.Left)
y += 1;
else if (type == ColorType.S && rotate == Rotate.Spawn)
y += 1;
else if (type == ColorType.S && rotate == Rotate.Right)
x += 1;
else if (type == ColorType.Z && rotate == Rotate.Spawn)
y += 1;
else if (type == ColorType.Z && rotate == Rotate.Left)
x -= 1;
return (TETFU_FIELD_TOP - y - 1) * TETFU_FIELD_WIDTH + x;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class LockedReachable 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;
lockedCache.clear();
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;
}
use of core.srs.Rotate in project solution-finder by knewjade.
the class AbstractAllOperationFactory method create.
public Set<T> create() {
HashSet<T> pieces = new HashSet<>();
HashSet<Mino> createdCheckSet = new HashSet<>();
for (Piece piece : Piece.values()) {
for (Rotate originRotate : Rotate.values()) {
Rotate rotate = minoShifter.createTransformedRotate(piece, originRotate);
Mino mino = minoFactory.create(piece, rotate);
// 追加済みかチェック
if (createdCheckSet.contains(mino))
continue;
createdCheckSet.add(mino);
// ミノの高さを計算
int minoHeight = mino.getMaxY() - mino.getMinY() + 1;
// フィールドの高さ以上にミノを使う場合はおけない
if (fieldHeight < minoHeight)
continue;
// 行候補をリストにする
ArrayList<Integer> lineIndexes = getLineIndexes(fieldHeight);
// リストアップ
ArrayList<T> piecesEachMino = generatePiecesEachMino(mino, lineIndexes, minoHeight);
// 追加
pieces.addAll(piecesEachMino);
}
}
return pieces;
}
Aggregations