Search in sources :

Example 6 with PiecesNumberComparator

use of common.comparator.PiecesNumberComparator in project solution-finder by knewjade.

the class ForwardOrderLookUpTest method parseOverBlocks.

@Test
void parseOverBlocks() throws Exception {
    List<Piece> pieceList = Arrays.asList(Piece.I, Piece.T, Piece.Z, Piece.O, Piece.I, Piece.L);
    int toDepth = pieceList.size() - 1;
    PiecesNumberComparator comparator = new PiecesNumberComparator();
    List<LongPieces> forward1 = OrderLookup.forwardBlocks(pieceList, toDepth).stream().map(StackOrder::toList).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
    ForwardOrderLookUp lookUp = new ForwardOrderLookUp(toDepth, pieceList.size());
    List<LongPieces> forward2 = lookUp.parse(pieceList).map(blockStream -> blockStream.collect(Collectors.toList())).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
    assertThat(forward2).isEqualTo(forward1);
}
Also used : Test(org.junit.jupiter.api.Test) HashSet(java.util.HashSet) Piece(core.mino.Piece) Randoms(lib.Randoms) Arrays(java.util.Arrays) List(java.util.List) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Test(org.junit.jupiter.api.Test)

Aggregations

PiecesNumberComparator (common.comparator.PiecesNumberComparator)6 LongPieces (common.datastore.blocks.LongPieces)6 Piece (core.mino.Piece)6 ArrayList (java.util.ArrayList)6 Arrays (java.util.Arrays)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Randoms (lib.Randoms)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Test (org.junit.jupiter.api.Test)6 Comparator (java.util.Comparator)4 ListComparator (lib.ListComparator)4 HashSet (java.util.HashSet)2