Search in sources :

Example 6 with Randoms

use of lib.Randoms 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 7 with Randoms

use of lib.Randoms 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 8 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class FullOperationSeparableMinoComparatorTest method compareMinoFieldEqual.

@Test
void compareMinoFieldEqual() {
    List<SeparableMino> minos = separableMinos.getMinos();
    Randoms randoms = new Randoms();
    int index = randoms.nextInt(minos.size());
    SeparableMino mino = minos.get(index);
    FullOperationSeparableMinoComparator comparator = new FullOperationSeparableMinoComparator();
    assertThat(comparator.compare(mino, mino)).isEqualTo(0);
}
Also used : Randoms(lib.Randoms) SeparableMino(searcher.pack.separable_mino.SeparableMino) Test(org.junit.jupiter.api.Test)

Example 9 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MinoFieldComparatorTest method compareMinoFieldDiffOuterField.

@Test
void compareMinoFieldDiffOuterField() {
    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(1L), separableMinos);
    MinoFieldComparator comparator = new MinoFieldComparator();
    assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2)).isEqualTo(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 10 with Randoms

use of lib.Randoms in project solution-finder by knewjade.

the class MinoFieldComparatorTest method compareMinoFieldEqual.

@Test
void compareMinoFieldEqual() {
    Randoms randoms = new Randoms();
    List<SeparableMino> minos = separableMinos.getMinos();
    SeparableMino mino = minos.get(0);
    RecursiveMinoField recursiveMinoField1 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
    RecursiveMinoField recursiveMinoField2 = new RecursiveMinoField(mino, ColumnFieldFactory.createField(), separableMinos);
    for (int count = 0; count < 10; count++) {
        int index = randoms.nextInt(0, minos.size() - 1);
        SeparableMino randomMino = minos.get(index);
        recursiveMinoField1 = new RecursiveMinoField(randomMino, recursiveMinoField1, ColumnFieldFactory.createField(), separableMinos);
        recursiveMinoField2 = new RecursiveMinoField(randomMino, recursiveMinoField2, ColumnFieldFactory.createField(), separableMinos);
    }
    MinoFieldComparator comparator = new MinoFieldComparator();
    assertThat(comparator.compare(recursiveMinoField1, recursiveMinoField2)).isEqualTo(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

Randoms (lib.Randoms)108 Test (org.junit.jupiter.api.Test)103 Piece (core.mino.Piece)58 LongTest (module.LongTest)32 Field (core.field.Field)29 Action (common.datastore.action.Action)25 LongPieces (common.datastore.blocks.LongPieces)24 MinoFactory (core.mino.MinoFactory)20 ArrayList (java.util.ArrayList)19 LockedCandidate (core.action.candidate.LockedCandidate)17 Mino (core.mino.Mino)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 MinoShifter (core.mino.MinoShifter)14 MinoRotation (core.srs.MinoRotation)14 Rotate (core.srs.Rotate)13 Collectors (java.util.stream.Collectors)13 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)12 PatternGenerator (common.pattern.PatternGenerator)12 List (java.util.List)12 SeparableMino (searcher.pack.separable_mino.SeparableMino)12