Search in sources :

Example 1 with PiecesNumberComparator

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

the class OrderLookupTest method forwardOver2BlocksRandom.

@Test
void forwardOver2BlocksRandom() throws Exception {
    Randoms randoms = new Randoms();
    for (int size = 4; size <= 13; size++) {
        List<Piece> pieceList = randoms.blocks(size);
        int toDepth = pieceList.size() - 2;
        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) Piece(core.mino.Piece) Randoms(lib.Randoms) Arrays(java.util.Arrays) List(java.util.List) ListComparator(lib.ListComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Test(org.junit.jupiter.api.Test)

Example 2 with PiecesNumberComparator

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

the class OrderLookupTest method forwardJustBlocksRandom.

@Test
void forwardJustBlocksRandom() throws Exception {
    Randoms randoms = new Randoms();
    for (int size = 2; size <= 13; size++) {
        List<Piece> pieceList = randoms.blocks(size);
        int toDepth = pieceList.size();
        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) Piece(core.mino.Piece) Randoms(lib.Randoms) Arrays(java.util.Arrays) List(java.util.List) ListComparator(lib.ListComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Test(org.junit.jupiter.api.Test)

Example 3 with PiecesNumberComparator

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

the class OrderLookupTest method reverseJustBlocksRandom.

@Test
void reverseJustBlocksRandom() throws Exception {
    Randoms randoms = new Randoms();
    for (int size = 1; size <= 13; size++) {
        List<Piece> pieceList = randoms.blocks(size);
        int fromDepth = pieceList.size();
        PiecesNumberComparator comparator = new PiecesNumberComparator();
        List<LongPieces> forward1 = OrderLookup.reverseBlocks(pieceList, fromDepth).stream().map(StackOrder::toList).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
        ReverseOrderLookUp lookUp = new ReverseOrderLookUp(pieceList.size(), fromDepth);
        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) Piece(core.mino.Piece) Randoms(lib.Randoms) Arrays(java.util.Arrays) List(java.util.List) ListComparator(lib.ListComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Test(org.junit.jupiter.api.Test)

Example 4 with PiecesNumberComparator

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

the class OrderLookupTest method forwardOverBlocksRandom.

@Test
void forwardOverBlocksRandom() throws Exception {
    Randoms randoms = new Randoms();
    for (int size = 3; size <= 13; size++) {
        List<Piece> pieceList = randoms.blocks(size);
        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) Piece(core.mino.Piece) Randoms(lib.Randoms) Arrays(java.util.Arrays) List(java.util.List) ListComparator(lib.ListComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) PiecesNumberComparator(common.comparator.PiecesNumberComparator) Test(org.junit.jupiter.api.Test)

Example 5 with PiecesNumberComparator

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

the class ForwardOrderLookUpTest method parseJustBlocks.

@Test
void parseJustBlocks() throws Exception {
    List<Piece> pieceList = Arrays.asList(Piece.I, Piece.T, Piece.Z, Piece.O, Piece.I, Piece.L);
    int toDepth = pieceList.size();
    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