Search in sources :

Example 56 with Mino

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");
}
Also used : DeltaLimitedMino(_implements.parity_based_pack.step1.DeltaLimitedMino) Mino(core.mino.Mino)

Example 57 with Mino

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;
}
Also used : Action(common.datastore.action.Action) Rotate(core.srs.Rotate) Mino(core.mino.Mino) HashSet(java.util.HashSet)

Example 58 with Mino

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;
}
Also used : Action(common.datastore.action.Action) Rotate(core.srs.Rotate) Mino(core.mino.Mino) HashSet(java.util.HashSet)

Example 59 with Mino

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

Example 60 with Mino

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