Search in sources :

Example 41 with MinoShifter

use of core.mino.MinoShifter in project solution-finder by knewjade.

the class CheckerUsingHoldCountTest method testBT4_5.

@Test
@LongTest
void testBT4_5() throws Exception {
    // Invoker
    List<Piece> pieces = Arrays.asList(I, T, S, Z, J, L, O);
    int popCount = 7;
    int maxClearLine = 6;
    int maxDepth = 7;
    // Field
    String marks = "" + "XX________" + "XX________" + "XXX______X" + "XXXXXXX__X" + "XXXXXX___X" + "XXXXXXX_XX" + "";
    Field field = FieldFactory.createField(marks);
    // Initialize
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    // Measure
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
    AnalyzeTree tree = new AnalyzeTree();
    Iterable<List<Piece>> combinations = new PermutationIterable<>(pieces, popCount);
    for (List<Piece> combination : combinations) {
        boolean result = checker.check(field, combination, candidate, maxClearLine, maxDepth);
        tree.set(result, combination);
    }
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(5038 / 5040.0);
}
Also used : Action(common.datastore.action.Action) PermutationIterable(common.iterable.PermutationIterable) AnalyzeTree(common.tree.AnalyzeTree) Field(core.field.Field) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) List(java.util.List) PerfectValidator(searcher.common.validator.PerfectValidator) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest) LongTest(module.LongTest)

Example 42 with MinoShifter

use of core.mino.MinoShifter in project solution-finder by knewjade.

the class CheckerUsingHoldCountTest method runTestCase.

private AnalyzeTree runTestCase(List<Piece> pieces, int popCount, int maxClearLine, int maxDepth, String marks) {
    Field field = FieldFactory.createField(marks);
    // Initialize
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    // Measure
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
    AnalyzeTree tree = new AnalyzeTree();
    Iterable<List<Piece>> combinations = new PermutationIterable<>(pieces, popCount);
    for (List<Piece> combination : combinations) {
        // Hold分の追加
        combination.add(0, Piece.T);
        boolean result = checker.check(field, combination, candidate, maxClearLine, maxDepth);
        tree.set(result, combination);
    }
    return tree;
}
Also used : Action(common.datastore.action.Action) PermutationIterable(common.iterable.PermutationIterable) AnalyzeTree(common.tree.AnalyzeTree) Field(core.field.Field) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) List(java.util.List) PerfectValidator(searcher.common.validator.PerfectValidator)

Example 43 with MinoShifter

use of core.mino.MinoShifter in project solution-finder by knewjade.

the class CheckerUsingHoldCountTest method testAfter4Line.

@Test
@LongTest
void testAfter4Line() throws Exception {
    // Invoker
    List<Piece> pieces = Arrays.asList(I, T, S, Z, J, L, O);
    int popCount = 7;
    int maxClearLine = 4;
    int maxDepth = 6;
    // Field
    String marks = "" + "XXXX______" + "XXXX______" + "XXXX______" + "XXXX______" + "";
    Field field = FieldFactory.createField(marks);
    // Initialize
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    // Measure
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
    AnalyzeTree tree = new AnalyzeTree();
    Iterable<List<Piece>> combinations = new PermutationIterable<>(pieces, popCount);
    for (List<Piece> combination : combinations) {
        boolean result = checker.check(field, combination, candidate, maxClearLine, maxDepth);
        tree.set(result, combination);
    }
    // Source: myself 20170415
    assertThat(tree.getSuccessPercent()).isEqualTo(5040 / 5040.0);
}
Also used : Action(common.datastore.action.Action) PermutationIterable(common.iterable.PermutationIterable) AnalyzeTree(common.tree.AnalyzeTree) Field(core.field.Field) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) List(java.util.List) PerfectValidator(searcher.common.validator.PerfectValidator) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest) LongTest(module.LongTest)

Example 44 with MinoShifter

use of core.mino.MinoShifter in project solution-finder by knewjade.

the class CheckerUsingHoldCountTest method testTemplateWithHoldI.

@Test
void testTemplateWithHoldI() throws Exception {
    // Invoker
    String pattern = "I, *p4";
    int maxClearLine = 4;
    int maxDepth = 4;
    // Field
    String marks = "" + "XXXXX_____" + "XXXXXX____" + "XXXXXXX___" + "XXXXXX____" + "";
    Field field = FieldFactory.createField(marks);
    // Initialize
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    PerfectValidator validator = new PerfectValidator();
    CheckerUsingHold<Action> checker = new CheckerUsingHold<>(minoFactory, validator);
    // Measure
    Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
    AnalyzeTree tree = new AnalyzeTree();
    PatternGenerator generator = new LoadedPatternGenerator(pattern);
    generator.blocksStream().forEach(blocks -> {
        List<Piece> pieceList = blocks.getPieces();
        boolean result = checker.check(field, pieceList, candidate, maxClearLine, maxDepth);
        tree.set(result, pieceList);
    });
    // Source: Nilgiri: https://docs.google.com/spreadsheets/d/1bVY3t_X96xRmUL0qdgB9tViSIGenu6RMKX4RW7qWg8Y/edit#gid=0
    assertThat(tree.getSuccessPercent()).isEqualTo(711 / 840.0);
}
Also used : Action(common.datastore.action.Action) PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) Field(core.field.Field) MinoRotation(core.srs.MinoRotation) LockedCandidate(core.action.candidate.LockedCandidate) Piece(core.mino.Piece) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) PerfectValidator(searcher.common.validator.PerfectValidator) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 45 with MinoShifter

use of core.mino.MinoShifter in project solution-finder by knewjade.

the class OnDemandBasicSolutionsFactoryTest method createSeparableMinos.

private static SeparableMinos createSeparableMinos(SizedBit sizedBit) {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    return SeparableMinos.createSeparableMinos(minoFactory, minoShifter, sizedBit);
}
Also used : MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter)

Aggregations

MinoShifter (core.mino.MinoShifter)60 MinoFactory (core.mino.MinoFactory)59 MinoRotation (core.srs.MinoRotation)39 Field (core.field.Field)36 Test (org.junit.jupiter.api.Test)35 LongTest (module.LongTest)29 Action (common.datastore.action.Action)22 ColumnField (core.column_field.ColumnField)19 Piece (core.mino.Piece)19 InOutPairField (searcher.pack.InOutPairField)18 Randoms (lib.Randoms)17 LockedReachable (core.action.reachable.LockedReachable)15 LockedCandidate (core.action.candidate.LockedCandidate)14 PermutationIterable (common.iterable.PermutationIterable)12 List (java.util.List)10 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 PerfectValidator (searcher.common.validator.PerfectValidator)10 SizedBit (searcher.pack.SizedBit)10 SolutionFilter (searcher.pack.memento.SolutionFilter)10