Search in sources :

Example 1 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.

the class CheckerNoHoldCountTest method testCase1.

@Test
void testCase1() throws Exception {
    // Invoker
    PatternGenerator blocksGenerator = new LoadedPatternGenerator("*p7");
    int maxClearLine = 4;
    int maxDepth = 6;
    // Field
    String marks = "" + "X________X" + "X________X" + "XX______XX" + "XXXXXX__XX" + "";
    AnalyzeTree tree = runTestCase(blocksGenerator, maxClearLine, maxDepth, marks);
    // Source: reply in twitter from @fullfool_14
    assertThat(tree.getSuccessPercent()).isEqualTo(1439 / 5040.0);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) AnalyzeTree(common.tree.AnalyzeTree) Test(org.junit.jupiter.api.Test)

Example 2 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateJustAny.

@Test
void enumerateJustAny() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator("T, O, S");
    HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(4);
    assertThat(core.getCounter()).isEqualTo(1);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LongPieces(common.datastore.blocks.LongPieces) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) Test(org.junit.jupiter.api.Test)

Example 3 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateMulti.

@Test
void enumerateMulti() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator(Arrays.asList("T, J, O, Z", "T, O, J, T", "T, J, O, Z"));
    HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(13);
    assertThat(core.getCounter()).isEqualTo(3);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LongPieces(common.datastore.blocks.LongPieces) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) Test(org.junit.jupiter.api.Test)

Example 4 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerate1.

@Test
void enumerate1() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator("*p7");
    HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(210);
    assertThat(core.getCounter()).isEqualTo(5040);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LongPieces(common.datastore.blocks.LongPieces) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) Test(org.junit.jupiter.api.Test)

Example 5 with LoadedPatternGenerator

use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateJustRandom.

@Test
void enumerateJustRandom() throws Exception {
    Randoms randoms = new Randoms();
    for (int size = 3; size <= 15; size++) {
        List<Piece> blocks = randoms.blocks(size);
        String pattern = blocks.stream().map(Piece::getName).collect(Collectors.joining(","));
        PatternGenerator blocksGenerator = new LoadedPatternGenerator(pattern);
        HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(blocksGenerator, size);
        Set<LongPieces> pieces = core.enumerate();
        for (int count = 0; count < 10000; count++) {
            ArrayList<Piece> sample = new ArrayList<>();
            int holdIndex = 0;
            for (int index = 1; index < size; index++) {
                if (randoms.nextBoolean(0.3)) {
                    // そのまま追加
                    sample.add(blocks.get(index));
                } else {
                    // ホールドを追加
                    sample.add(blocks.get(holdIndex));
                    holdIndex = index;
                }
            }
            // ホールドを追加
            sample.add(blocks.get(holdIndex));
            assertThat(new LongPieces(sample)).isIn(pieces);
        }
    }
}
Also used : Randoms(lib.Randoms) PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)61 PatternGenerator (common.pattern.PatternGenerator)61 Test (org.junit.jupiter.api.Test)35 LongPieces (common.datastore.blocks.LongPieces)31 AnalyzeTree (common.tree.AnalyzeTree)30 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)25 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)25 Piece (core.mino.Piece)11 Randoms (lib.Randoms)8 LongTest (module.LongTest)7 HashSet (java.util.HashSet)4 Pieces (common.datastore.blocks.Pieces)2 Field (core.field.Field)2 MinoFactory (core.mino.MinoFactory)2 ArrayList (java.util.ArrayList)2 Injector (com.google.inject.Injector)1 Action (common.datastore.action.Action)1 LockedCandidateThreadLocal (concurrent.LockedCandidateThreadLocal)1 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)1 LockedCandidate (core.action.candidate.LockedCandidate)1