Search in sources :

Example 96 with Randoms

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

the class PassedMinoShifterTest method enumerateSameOtherActions.

@Test
void enumerateSameOtherActions() {
    Randoms randoms = new Randoms();
    PassedMinoShifter minoShifter = new PassedMinoShifter();
    for (int count = 0; count < 10000; count++) {
        Piece piece = randoms.block();
        Rotate rotate = randoms.rotate();
        int x = randoms.nextInt(10);
        int y = randoms.nextInt(0, 12);
        List<Action> actions = minoShifter.enumerateSameOtherActions(piece, rotate, x, y);
        assertThat(actions).isEmpty();
    }
}
Also used : Randoms(lib.Randoms) Action(common.datastore.action.Action) MinimalAction(common.datastore.action.MinimalAction) Rotate(core.srs.Rotate) Test(org.junit.jupiter.api.Test)

Example 97 with Randoms

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

the class PassedMinoShifterTest method createTransformedAction.

@Test
void createTransformedAction() {
    Randoms randoms = new Randoms();
    PassedMinoShifter minoShifter = new PassedMinoShifter();
    for (int count = 0; count < 10000; count++) {
        Piece piece = randoms.block();
        Rotate rotate = randoms.rotate();
        int x = randoms.nextInt(10);
        int y = randoms.nextInt(0, 12);
        MinimalAction action = MinimalAction.create(x, y, rotate);
        Action actualAction = minoShifter.createTransformedAction(piece, action);
        assertThat(actualAction).isEqualTo(action);
    }
}
Also used : Randoms(lib.Randoms) Action(common.datastore.action.Action) MinimalAction(common.datastore.action.MinimalAction) MinimalAction(common.datastore.action.MinimalAction) Rotate(core.srs.Rotate) Test(org.junit.jupiter.api.Test)

Example 98 with Randoms

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

the class PassedMinoShifterTest method createTransformedRotate.

@Test
void createTransformedRotate() {
    Randoms randoms = new Randoms();
    PassedMinoShifter minoShifter = new PassedMinoShifter();
    for (int count = 0; count < 10000; count++) {
        Piece piece = randoms.block();
        Rotate rotate = randoms.rotate();
        Rotate actualRotate = minoShifter.createTransformedRotate(piece, rotate);
        assertThat(actualRotate).isEqualTo(rotate);
    }
}
Also used : Randoms(lib.Randoms) Rotate(core.srs.Rotate) Test(org.junit.jupiter.api.Test)

Example 99 with Randoms

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

the class NeighborTest method getNextRightRotateSources.

@Test
void getNextRightRotateSources() {
    OriginalPiece piece = new OriginalPiece(new Mino(Piece.T, Rotate.Spawn), 1, 0, 4);
    Neighbor neighbor = new Neighbor(piece);
    OriginalPieceFactory factory = new OriginalPieceFactory(4);
    List<OriginalPiece> pieces = new ArrayList<>(factory.create());
    Randoms randoms = new Randoms();
    List<Neighbor> samples = randoms.sample(pieces, 4).stream().map(Neighbor::new).collect(Collectors.toList());
    neighbor.updateRightRotateSource(samples);
    assertThat(neighbor.getNextRightRotateSources()).containsAll(samples);
}
Also used : Randoms(lib.Randoms) ArrayList(java.util.ArrayList) Mino(core.mino.Mino) Test(org.junit.jupiter.api.Test)

Example 100 with Randoms

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

the class FieldViewTest method testRandom.

@Test
void testRandom() {
    Randoms randoms = new Randoms();
    String lineSeparator = System.lineSeparator();
    int width = 10;
    for (int count = 0; count < 10000; count++) {
        int height = randoms.nextIntClosed(1, 12);
        boolean[][] fields = new boolean[height][width];
        for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) fields[y][x] = randoms.nextBoolean();
        StringBuilder builder = new StringBuilder();
        for (int y = height - 1; 0 <= y; y--) {
            for (int x = 0; x < width; x++) {
                boolean isEmpty = fields[y][x];
                builder.append(isEmpty ? '_' : 'X');
            }
            if (y != 0)
                builder.append(lineSeparator);
        }
        String marks = builder.toString();
        Field field = FieldFactory.createField(marks.replace(lineSeparator, ""));
        String string = FieldView.toString(field, height);
        assertThat(string).isEqualTo(marks);
    }
}
Also used : Randoms(lib.Randoms) 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