Search in sources :

Example 61 with Mino

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;
}
Also used : Rotate(core.srs.Rotate) Mino(core.mino.Mino)

Example 62 with Mino

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);
        }
    }
}
Also used : Action(common.datastore.action.Action) Piece(core.mino.Piece) OriginalPiece(core.neighbor.OriginalPiece) Neighbor(core.neighbor.Neighbor) Mino(core.mino.Mino) OriginalPiece(core.neighbor.OriginalPiece)

Example 63 with Mino

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);
}
Also used : Mino(core.mino.Mino)

Example 64 with Mino

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;
}
Also used : Rotate(core.srs.Rotate) Mino(core.mino.Mino)

Example 65 with Mino

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);
}
Also used : Field(core.field.Field) ArrayList(java.util.ArrayList) Mino(core.mino.Mino)

Aggregations

Mino (core.mino.Mino)103 Test (org.junit.jupiter.api.Test)46 Rotate (core.srs.Rotate)27 Field (core.field.Field)24 Piece (core.mino.Piece)20 Randoms (lib.Randoms)16 MinoFactory (core.mino.MinoFactory)14 ColorType (common.tetfu.common.ColorType)12 ColoredField (common.tetfu.field.ColoredField)12 ArrayList (java.util.ArrayList)12 FullOperationWithKey (common.datastore.FullOperationWithKey)9 HashSet (java.util.HashSet)9 ColorConverter (common.tetfu.common.ColorConverter)8 OriginalPiece (core.neighbor.OriginalPiece)8 List (java.util.List)8 MinoOperationWithKey (common.datastore.MinoOperationWithKey)7 OperationWithKey (common.datastore.OperationWithKey)7 TetfuPage (common.tetfu.TetfuPage)7 Arrays (java.util.Arrays)7 Collectors (java.util.stream.Collectors)7