Search in sources :

Example 11 with MinoShifter

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

the class SeparableMinosTest method createSeparableMinoSet.

private Set<SeparableMino> createSeparableMinoSet() {
    Randoms randoms = new Randoms();
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    int fieldHeight = randoms.nextIntClosed(1, 10);
    int fieldWidth = randoms.nextIntClosed(1, 4);
    SizedBit sizedBit = new SizedBit(fieldWidth, fieldHeight);
    AllSeparableMinoFactory separableMinoFactory = new AllSeparableMinoFactory(minoFactory, minoShifter, sizedBit.getWidth(), sizedBit.getHeight(), sizedBit.getFillBoard());
    return separableMinoFactory.create();
}
Also used : Randoms(lib.Randoms) MinoFactory(core.mino.MinoFactory) AllSeparableMinoFactory(searcher.pack.separable_mino.AllSeparableMinoFactory) MinoShifter(core.mino.MinoShifter) AllSeparableMinoFactory(searcher.pack.separable_mino.AllSeparableMinoFactory)

Example 12 with MinoShifter

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

the class AllSeparableMinoFactoryTest method create2x3.

@Test
void create2x3() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    int width = 2;
    int height = 3;
    Set<SeparableMino> minos = getSeparableMinos(minoFactory, minoShifter, width, height);
    assertThat(minos.stream()).hasSize(76);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.T))).hasSize(16);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.I))).hasSize(6);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.S))).hasSize(8);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.Z))).hasSize(8);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.O))).hasSize(6);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.L))).hasSize(16);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.J))).hasSize(16);
}
Also used : MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test)

Example 13 with MinoShifter

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

the class AllSeparableMinoFactoryTest method create3x4.

@Test
void create3x4() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    int width = 3;
    int height = 4;
    Set<SeparableMino> minos = getSeparableMinos(minoFactory, minoShifter, width, height);
    assertThat(minos.stream()).hasSize(273);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.T))).hasSize(60);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.I))).hasSize(15);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.S))).hasSize(30);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.Z))).hasSize(30);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.O))).hasSize(18);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.L))).hasSize(60);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.J))).hasSize(60);
}
Also used : MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test)

Example 14 with MinoShifter

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

the class AllSeparableMinoFactoryTest method create2x4.

@Test
void create2x4() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    int width = 2;
    int height = 4;
    Set<SeparableMino> minos = getSeparableMinos(minoFactory, minoShifter, width, height);
    for (SeparableMino separableMino : minos) {
        ColumnField field = separableMino.getColumnField();
        System.out.println(ColumnFieldView.toString(field, 5, 4));
        System.out.println("===");
    }
    assertThat(minos.stream()).hasSize(182);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.T))).hasSize(40);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.I))).hasSize(10);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.S))).hasSize(20);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.Z))).hasSize(20);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.O))).hasSize(12);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.L))).hasSize(40);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.J))).hasSize(40);
}
Also used : ColumnField(core.column_field.ColumnField) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test)

Example 15 with MinoShifter

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

the class AllSeparableMinoFactoryTest method create2x5.

@Test
void create2x5() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    int width = 2;
    int height = 5;
    Set<SeparableMino> minos = getSeparableMinos(minoFactory, minoShifter, width, height);
    assertThat(minos.stream()).hasSize(360);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.T))).hasSize(80);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.I))).hasSize(20);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.S))).hasSize(40);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.Z))).hasSize(40);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.O))).hasSize(20);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.L))).hasSize(80);
    assertThat(minos.stream().filter(createBlockPredicate(Piece.J))).hasSize(80);
}
Also used : MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test)

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