Search in sources :

Example 6 with RecursiveMinoField

use of searcher.pack.mino_field.RecursiveMinoField in project solution-finder by knewjade.

the class MinoFieldComparatorTest method compareMinoFieldDiffMino.

@Test
void compareMinoFieldDiffMino() {
    Randoms randoms = new Randoms();
    List<SeparableMino> minos = separableMinos.getMinos();
    MinoFieldComparator comparator = new MinoFieldComparator();
    for (int count = 0; count < 100000; count++) {
        int index1 = randoms.nextInt(0, minos.size());
        SeparableMino mino1 = minos.get(index1);
        RecursiveMinoField recursiveMinoField1 = new RecursiveMinoField(mino1, ColumnFieldFactory.createField(), separableMinos);
        int index2 = randoms.nextInt(0, minos.size() - 1);
        if (index1 == index2)
            index2 += 1;
        SeparableMino mino2 = minos.get(index2);
        RecursiveMinoField recursiveMinoField2 = new RecursiveMinoField(mino2, ColumnFieldFactory.createField(), separableMinos);
        // assert is not 0 & sign reversed
        assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2) * comparator.compare(recursiveMinoField2, recursiveMinoField1)).isLessThan(0);
    }
}
Also used : Randoms(lib.Randoms) SeparableMino(searcher.pack.separable_mino.SeparableMino) RecursiveMinoField(searcher.pack.mino_field.RecursiveMinoField) Test(org.junit.jupiter.api.Test)

Example 7 with RecursiveMinoField

use of searcher.pack.mino_field.RecursiveMinoField in project solution-finder by knewjade.

the class MinoFieldComparatorTest method compareMinoFieldDiffSize.

@Test
void compareMinoFieldDiffSize() {
    Randoms randoms = new Randoms();
    List<SeparableMino> minos = separableMinos.getMinos();
    int index = randoms.nextInt(0, minos.size() - 1);
    SeparableMino mino = minos.get(index);
    RecursiveMinoField recursiveMinoField1 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
    RecursiveMinoField recursiveMinoField2 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
    recursiveMinoField2 = new RecursiveMinoField(mino, recursiveMinoField2, ColumnFieldFactory.createField(), separableMinos);
    // assert is not 0 & sign reversed
    MinoFieldComparator comparator = new MinoFieldComparator();
    assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2) * comparator.compare(recursiveMinoField2, recursiveMinoField1)).isLessThan(0);
}
Also used : Randoms(lib.Randoms) SeparableMino(searcher.pack.separable_mino.SeparableMino) RecursiveMinoField(searcher.pack.mino_field.RecursiveMinoField) Test(org.junit.jupiter.api.Test)

Aggregations

RecursiveMinoField (searcher.pack.mino_field.RecursiveMinoField)7 SeparableMino (searcher.pack.separable_mino.SeparableMino)7 Randoms (lib.Randoms)4 Test (org.junit.jupiter.api.Test)4 ColumnField (core.column_field.ColumnField)3 Field (core.field.Field)3 SeparableMinos (searcher.pack.SeparableMinos)3 OperationWithKey (common.datastore.OperationWithKey)2 List (java.util.List)2 Objects (java.util.Objects)2 Callable (java.util.concurrent.Callable)2 Stream (java.util.stream.Stream)2 ColumnFieldConnection (searcher.pack.connections.ColumnFieldConnection)2 ColumnFieldConnections (searcher.pack.connections.ColumnFieldConnections)2 StreamColumnFieldConnections (searcher.pack.connections.StreamColumnFieldConnections)2 RecursiveMinoFields (searcher.pack.mino_fields.RecursiveMinoFields)2