Search in sources :

Example 1 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class PiecesNameComparatorTest method compareDiffSize.

@Test
void compareDiffSize() throws Exception {
    LongPieces pieces1 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I));
    LongPieces pieces2 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I, Piece.J));
    // assert is not 0 & sign reversed
    PiecesNameComparator comparator = new PiecesNameComparator();
    assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
}
Also used : LongPieces(common.datastore.blocks.LongPieces) Test(org.junit.jupiter.api.Test)

Example 2 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class PiecesNameComparatorTest method compareDiffRandom.

@Test
void compareDiffRandom() throws Exception {
    List<Piece> allPieces = Arrays.asList(Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L, Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L);
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        List<Piece> blocks1 = randoms.sample(allPieces, randoms.nextInt(10));
        List<Piece> blocks2 = randoms.sample(allPieces, randoms.nextInt(10));
        if (blocks1.equals(blocks2))
            blocks1.add(Piece.O);
        LongPieces pieces1 = new LongPieces(blocks1);
        LongPieces pieces2 = new LongPieces(blocks2);
        // assert is not 0 & sign reversed
        PiecesNameComparator comparator = new PiecesNameComparator();
        assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
    }
}
Also used : Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) Test(org.junit.jupiter.api.Test)

Example 3 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class PiecesNumberComparatorTest method compareDiffSize.

@Test
void compareDiffSize() throws Exception {
    LongPieces pieces1 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I));
    LongPieces pieces2 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I, Piece.J));
    // assert is not 0 & sign reversed
    PiecesNumberComparator comparator = new PiecesNumberComparator();
    assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
}
Also used : LongPieces(common.datastore.blocks.LongPieces) Test(org.junit.jupiter.api.Test)

Example 4 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class PiecesNumberComparatorTest method compareDiffRandom.

@Test
void compareDiffRandom() throws Exception {
    List<Piece> allPieces = Arrays.asList(Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L, Piece.T, Piece.I, Piece.O, Piece.S, Piece.Z, Piece.J, Piece.L);
    Randoms randoms = new Randoms();
    for (int count = 0; count < 10000; count++) {
        List<Piece> blocks1 = randoms.sample(allPieces, randoms.nextInt(10));
        List<Piece> blocks2 = randoms.sample(allPieces, randoms.nextInt(10));
        if (blocks1.equals(blocks2))
            blocks1.add(Piece.O);
        LongPieces pieces1 = new LongPieces(blocks1);
        LongPieces pieces2 = new LongPieces(blocks2);
        // assert is not 0 & sign reversed
        PiecesNumberComparator comparator = new PiecesNumberComparator();
        assertThat(comparator.compare(pieces1, pieces2) * comparator.compare(pieces2, pieces1)).as(pieces2.toString()).isLessThan(0);
    }
}
Also used : Randoms(lib.Randoms) Piece(core.mino.Piece) LongPieces(common.datastore.blocks.LongPieces) Test(org.junit.jupiter.api.Test)

Example 5 with LongPieces

use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.

the class PiecesNumberComparatorTest method compare.

@Test
void compare() throws Exception {
    LongPieces pieces1 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I));
    LongPieces pieces2 = new LongPieces(Arrays.asList(Piece.T, Piece.O, Piece.I));
    PiecesNumberComparator comparator = new PiecesNumberComparator();
    assertThat(comparator.compare(pieces1, pieces2)).isEqualTo(0);
    assertThat(comparator.compare(pieces2, pieces1)).isEqualTo(0);
}
Also used : LongPieces(common.datastore.blocks.LongPieces) Test(org.junit.jupiter.api.Test)

Aggregations

LongPieces (common.datastore.blocks.LongPieces)71 Test (org.junit.jupiter.api.Test)58 Piece (core.mino.Piece)42 PatternGenerator (common.pattern.PatternGenerator)38 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)36 Randoms (lib.Randoms)27 Collectors (java.util.stream.Collectors)22 Field (core.field.Field)19 Pieces (common.datastore.blocks.Pieces)16 LongTest (module.LongTest)16 List (java.util.List)14 Stream (java.util.stream.Stream)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 FieldFactory (core.field.FieldFactory)12 ArrayList (java.util.ArrayList)12 SizedBit (searcher.pack.SizedBit)12 MinoFactory (core.mino.MinoFactory)11 HashSet (java.util.HashSet)11 ExecutionException (java.util.concurrent.ExecutionException)10 BlockInterpreter (common.parser.BlockInterpreter)9