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();
}
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();
}
Aggregations