use of module.BasicModule in project solution-finder by knewjade.
the class LockedNeighborReachableTest method randoms.
@Test
void randoms() {
int maxClearLine = 4;
Injector injector = Guice.createInjector(new BasicModule(maxClearLine));
LockedReachable reachable1 = createLockedReachable(injector, maxClearLine);
LockedNeighborReachable reachable2 = createLockedNeighborReachable(injector, maxClearLine);
OriginalPieceFactory pieceFactory = injector.getInstance(OriginalPieceFactory.class);
Set<OriginalPiece> pieces = pieceFactory.create();
Randoms randoms = new Randoms();
for (int count = 0; count < 10000; count++) {
Field field = randoms.field(4, 5);
for (OriginalPiece piece : pieces) {
// フィールドにそもそも置けないときは前提条件が合わないためスキップ
if (!field.canPut(piece))
continue;
Mino mino = piece.getMino();
int x = piece.getX();
int y = piece.getY();
boolean checks1 = reachable1.checks(field, mino, x, y, maxClearLine);
boolean checks2 = reachable2.checks(field, mino, x, y, maxClearLine);
assertThat(checks2).as(piece.toString()).isEqualTo(checks1);
}
}
}
use of module.BasicModule in project solution-finder by knewjade.
the class LockedNeighborReachableTest method checks2.
@Test
void checks2() {
int maxClearLine = 4;
Injector injector = Guice.createInjector(new BasicModule(maxClearLine));
LockedNeighborReachable reachable = createLockedNeighborReachable(injector, maxClearLine);
Field field = FieldFactory.createField("" + "X______XXX" + "XXXXXX___X" + "XXX_____XX" + "XXX______X");
boolean checks = reachable.checks(field, new Mino(Piece.J, Rotate.Spawn), 4, 0, maxClearLine);
assertThat(checks).isFalse();
}
use of module.BasicModule in project solution-finder by knewjade.
the class NeighborsTest method nextLeftRotateDestinations.
@Test
void nextLeftRotateDestinations() {
Injector injector = Guice.createInjector(new BasicModule(6));
Neighbors neighbors = createNeighbors(injector);
Neighbor neighbor = neighbors.get(Piece.T, Rotate.Spawn, 4, 3);
assertThat(neighbor.getNextLeftRotateDestinations()).containsExactlyInAnyOrder(neighbors.get(Piece.T, Rotate.Left, 4, 3), neighbors.get(Piece.T, Rotate.Left, 5, 3), neighbors.get(Piece.T, Rotate.Left, 5, 4), neighbors.get(Piece.T, Rotate.Left, 4, 1), neighbors.get(Piece.T, Rotate.Left, 5, 1));
}
use of module.BasicModule in project solution-finder by knewjade.
the class NeighborsTest method nextRightRotateSources.
@Test
void nextRightRotateSources() {
Injector injector = Guice.createInjector(new BasicModule(6));
Neighbors neighbors = createNeighbors(injector);
Neighbor neighbor = neighbors.get(Piece.T, Rotate.Spawn, 4, 3);
assertThat(neighbor.getNextRightRotateSources()).containsExactlyInAnyOrder(neighbors.get(Piece.T, Rotate.Left, 4, 3), neighbors.get(Piece.T, Rotate.Left, 5, 3), neighbors.get(Piece.T, Rotate.Left, 5, 4), neighbors.get(Piece.T, Rotate.Left, 4, 1), neighbors.get(Piece.T, Rotate.Left, 5, 1));
}
use of module.BasicModule in project solution-finder by knewjade.
the class PercentCoreTest method assertPercentCore.
private void assertPercentCore(Obj obj, double successPercent) throws Exception {
PatternGenerator generator = new LoadedPatternGenerator(obj.patterns);
NormalEnumeratePieces enumeratePieces = new NormalEnumeratePieces(generator, obj.maxDepth, obj.isUsingHold);
Set<LongPieces> blocks = enumeratePieces.enumerate();
Injector injector = Guice.createInjector(new BasicModule(obj.maxClearLine));
Optional<ExecutorService> executorService = obj.isSingleThread ? Optional.empty() : Optional.of(injector.getInstance(ExecutorService.class));
LockedCandidateThreadLocal candidateThreadLocal = injector.getInstance(LockedCandidateThreadLocal.class);
LockedReachableThreadLocal reachableThreadLocal = injector.getInstance(LockedReachableThreadLocal.class);
MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
PercentCore percentCore = getPercentCore(obj, executorService.orElse(null), candidateThreadLocal, reachableThreadLocal, minoFactory);
Field field = FieldFactory.createField(obj.marks);
percentCore.run(field, blocks, obj.maxClearLine, obj.maxDepth);
executorService.ifPresent(ExecutorService::shutdown);
assertThat(percentCore.getResultTree().getSuccessPercent()).isEqualTo(successPercent);
}
Aggregations