Search in sources :

Example 11 with Neighbor

use of core.neighbor.Neighbor in project solution-finder by knewjade.

the class LockedNeighborCandidateTest method testField.

@ParameterizedTest
@ArgumentsSource(FieldTestCase.class)
void testField(Field field, Piece piece) {
    Injector injector = Guice.createInjector(new BasicModule());
    int maxClearLine = 4;
    LockedCandidate candidate1 = createLockedCandidate(injector, maxClearLine);
    LockedNeighborCandidate candidate2 = createLockedNeighborCandidate(injector, maxClearLine);
    MinoShifter minoShifter = injector.getInstance(MinoShifter.class);
    // LockedCandidate
    Set<Action> search1 = candidate1.search(field, piece, maxClearLine);
    // LockedNeighborCandidate
    Set<Neighbor> neighbors = candidate2.search(field, piece, maxClearLine);
    Set<Action> search2 = neighbors.stream().map(Neighbor::getPiece).map(this::createMinimalAction).map(action -> minoShifter.createTransformedAction(piece, action)).collect(Collectors.toSet());
    assertThat(search2).isEqualTo(search1);
}
Also used : MinimalAction(common.datastore.action.MinimalAction) Randoms(lib.Randoms) Stopwatch(lib.Stopwatch) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BasicModule(module.BasicModule) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Action(common.datastore.action.Action) Neighbor(core.neighbor.Neighbor) MinoFactory(core.mino.MinoFactory) FieldFactory(core.field.FieldFactory) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) MinoRotation(core.srs.MinoRotation) MinoShifter(core.mino.MinoShifter) Piece(core.mino.Piece) OriginalPieceFactory(core.neighbor.OriginalPieceFactory) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Injector(com.google.inject.Injector) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Field(core.field.Field) Stream(java.util.stream.Stream) Guice(com.google.inject.Guice) OriginalPiece(core.neighbor.OriginalPiece) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource) MinimalAction(common.datastore.action.MinimalAction) Action(common.datastore.action.Action) Injector(com.google.inject.Injector) BasicModule(module.BasicModule) Neighbor(core.neighbor.Neighbor) MinoShifter(core.mino.MinoShifter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

Neighbor (core.neighbor.Neighbor)11 OriginalPiece (core.neighbor.OriginalPiece)6 Action (common.datastore.action.Action)4 Piece (core.mino.Piece)4 Rotate (core.srs.Rotate)3 Guice (com.google.inject.Guice)2 Injector (com.google.inject.Injector)2 MinimalAction (common.datastore.action.MinimalAction)2 Field (core.field.Field)2 FieldFactory (core.field.FieldFactory)2 Mino (core.mino.Mino)2 MinoFactory (core.mino.MinoFactory)2 MinoShifter (core.mino.MinoShifter)2 OriginalPieceFactory (core.neighbor.OriginalPieceFactory)2 MinoRotation (core.srs.MinoRotation)2 Set (java.util.Set)2 TimeUnit (java.util.concurrent.TimeUnit)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Randoms (lib.Randoms)2