Search in sources :

Example 11 with MinoFactory

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

the class CheckmateUsingHoldTest method assertResult.

private void assertResult(Result result, Field field, int maxClearLine, LockedReachable reachable, List<Piece> blocks) {
    // Check blocks is same
    List<Piece> resultPieces = parseToBlocks(result);
    Piece lastHoldPiece = result.getLastHold();
    HashSet<LongPieces> pieces = OrderLookup.reverseBlocks(resultPieces, blocks.size()).stream().map(StackOrder::toStream).map(stream -> stream.map(block -> block != null ? block : lastHoldPiece)).map(LongPieces::new).collect(Collectors.toCollection(HashSet::new));
    assertThat(pieces).contains(new LongPieces(blocks));
    // Check can build result
    Operations operations = parseToOperations(result);
    List<MinoOperationWithKey> operationWithKeys = OperationTransform.parseToOperationWithKeys(field, operations, minoFactory, maxClearLine);
    boolean cansBuild = BuildUp.cansBuild(field, operationWithKeys, maxClearLine, reachable);
    assertThat(cansBuild).isTrue();
}
Also used : java.util(java.util) Pieces(common.datastore.blocks.Pieces) OperationTransform(common.parser.OperationTransform) common.datastore(common.datastore) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) ResultHelper(common.ResultHelper) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) LockedCandidate(core.action.candidate.LockedCandidate) Action(common.datastore.action.Action) MinoFactory(core.mino.MinoFactory) PerfectValidator(searcher.common.validator.PerfectValidator) OrderLookup(common.order.OrderLookup) Candidate(core.action.candidate.Candidate) FieldFactory(core.field.FieldFactory) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) MinoRotation(core.srs.MinoRotation) StackOrder(common.order.StackOrder) LockedReachable(core.action.reachable.LockedReachable) MinoShifter(core.mino.MinoShifter) Piece(core.mino.Piece) Files(java.nio.file.Files) BuildUp(common.buildup.BuildUp) BlockInterpreter(common.parser.BlockInterpreter) IOException(java.io.IOException) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Field(core.field.Field) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) LongTest(module.LongTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces)

Example 12 with MinoFactory

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

the class FullOperationSeparableMinoComparatorTest method createSeparableMinos.

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

Example 13 with MinoFactory

use of core.mino.MinoFactory 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 14 with MinoFactory

use of core.mino.MinoFactory 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 15 with MinoFactory

use of core.mino.MinoFactory 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)

Aggregations

MinoFactory (core.mino.MinoFactory)113 Test (org.junit.jupiter.api.Test)70 MinoShifter (core.mino.MinoShifter)59 LongTest (module.LongTest)51 Field (core.field.Field)45 MinoRotation (core.srs.MinoRotation)40 ColorConverter (common.tetfu.common.ColorConverter)33 Piece (core.mino.Piece)28 Action (common.datastore.action.Action)22 ColumnField (core.column_field.ColumnField)22 Randoms (lib.Randoms)22 InOutPairField (searcher.pack.InOutPairField)21 LockedReachable (core.action.reachable.LockedReachable)17 PerfectValidator (searcher.common.validator.PerfectValidator)17 LockedCandidate (core.action.candidate.LockedCandidate)16 MinoOperationWithKey (common.datastore.MinoOperationWithKey)15 List (java.util.List)15 Collectors (java.util.stream.Collectors)15 PermutationIterable (common.iterable.PermutationIterable)12 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)12