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