Search in sources :

Example 56 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateOverAny.

@Test
void enumerateOverAny() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator("T, J, O, Z");
    HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(8);
    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 57 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateJust.

@Test
void enumerateJust() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator("*p3");
    HoldBreakEnumeratePieces core = new HoldBreakEnumeratePieces(generator, 3);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(210);
    assertThat(core.getCounter()).isEqualTo(210);
}
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 58 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class HoldBreakEnumeratePiecesTest method enumerateOverRandom.

@Test
void enumerateOverRandom() 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 - 1);
        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;
                }
            }
            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)

Example 59 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class NormalEnumeratePiecesTest method enumerateHoldOver1.

@Test
void enumerateHoldOver1() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator("*p7");
    NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 3, true);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(840);
    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 60 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class NormalEnumeratePiecesTest method enumerateNoHoldJustMulti.

@Test
void enumerateNoHoldJustMulti() throws Exception {
    PatternGenerator generator = new LoadedPatternGenerator(Arrays.asList("T, J, O, Z", "J, O, S, T", "T, J, O, I"));
    NormalEnumeratePieces core = new NormalEnumeratePieces(generator, 4, false);
    Set<LongPieces> pieces = core.enumerate();
    assertThat(pieces).hasSize(3);
    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)

Aggregations

LongPieces (common.datastore.blocks.LongPieces)71 Test (org.junit.jupiter.api.Test)58 Piece (core.mino.Piece)42 PatternGenerator (common.pattern.PatternGenerator)38 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)36 Randoms (lib.Randoms)27 Collectors (java.util.stream.Collectors)22 Field (core.field.Field)19 Pieces (common.datastore.blocks.Pieces)16 LongTest (module.LongTest)16 List (java.util.List)14 Stream (java.util.stream.Stream)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 FieldFactory (core.field.FieldFactory)12 ArrayList (java.util.ArrayList)12 SizedBit (searcher.pack.SizedBit)12 MinoFactory (core.mino.MinoFactory)11 HashSet (java.util.HashSet)11 ExecutionException (java.util.concurrent.ExecutionException)10 BlockInterpreter (common.parser.BlockInterpreter)9