Search in sources :

Example 1 with StackOrder

use of common.order.StackOrder 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 2 with StackOrder

use of common.order.StackOrder 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)

Aggregations

ResultHelper (common.ResultHelper)2 BuildUp (common.buildup.BuildUp)2 common.datastore (common.datastore)2 Action (common.datastore.action.Action)2 LongPieces (common.datastore.blocks.LongPieces)2 OrderLookup (common.order.OrderLookup)2 StackOrder (common.order.StackOrder)2 BlockInterpreter (common.parser.BlockInterpreter)2 OperationTransform (common.parser.OperationTransform)2 Candidate (core.action.candidate.Candidate)2 LockedCandidate (core.action.candidate.LockedCandidate)2 LockedReachable (core.action.reachable.LockedReachable)2 Field (core.field.Field)2 FieldFactory (core.field.FieldFactory)2 MinoFactory (core.mino.MinoFactory)2 MinoShifter (core.mino.MinoShifter)2 Piece (core.mino.Piece)2 MinoRotation (core.srs.MinoRotation)2 IOException (java.io.IOException)2 Files (java.nio.file.Files)2