Search in sources :

Example 21 with MinoFactory

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

the class MappedBasicSolutionsTest 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)

Example 22 with MinoFactory

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

the class PackSearcherComparingParityBasedOnDemandTest 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)

Example 23 with MinoFactory

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

the class PackSearcherComparingParityBasedTest 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)

Example 24 with MinoFactory

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

the class CheckerUsingHoldTest method assertResult.

private void assertResult(Field field, int maxClearLine, LockedReachable reachable, List<Piece> blocks) {
    Result result = checker.getResult();
    // 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 : Randoms(lib.Randoms) java.util(java.util) 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 25 with MinoFactory

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

the class LimitIterationCandidateTest method testSearch2.

@Test
void testSearch2() throws Exception {
    MinoFactory minoFactory = new MinoFactory();
    MinoShifter minoShifter = new MinoShifter();
    MinoRotation minoRotation = new MinoRotation();
    Candidate<Action> candidate = new LimitIterationCandidate(minoFactory, minoShifter, minoRotation, 3);
    String marks = "" + "XXXX______" + "XXXXX_____" + "X___X_____" + "XX_XX_____";
    Field field = FieldFactory.createField(marks);
    Set<Action> actions = candidate.search(field, Piece.T, 4);
    assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Spawn)).hasSize(3);
    assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Right)).hasSize(4);
    assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Reverse)).hasSize(4);
    assertThat(actions.stream().filter((e) -> e.getRotate() == Rotate.Left)).hasSize(4);
}
Also used : MinoRotation(core.srs.MinoRotation) Field(core.field.Field) MinimalAction(common.datastore.action.MinimalAction) Action(common.datastore.action.Action) MinoFactory(core.mino.MinoFactory) MinoShifter(core.mino.MinoShifter) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

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