Search in sources :

Example 36 with Mino

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;
}
Also used : BlockField(common.datastore.BlockField) Field(core.field.Field) ColoredField(common.tetfu.field.ColoredField) MinoOperationWithKey(common.datastore.MinoOperationWithKey) BlockField(common.datastore.BlockField) Mino(core.mino.Mino)

Example 37 with Mino

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

Example 38 with Mino

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

Example 39 with Mino

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

Example 40 with Mino

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

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