use of core.mino.Mino 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 core.mino.Mino 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 core.mino.Mino 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);
}
use of core.mino.Mino in project solution-finder by knewjade.
the class OriginalPieceTest method testHashCodeDiffFieldHeight.
@Test
void testHashCodeDiffFieldHeight() {
OriginalPiece piece1 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 10);
OriginalPiece piece2 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 5);
assertThat(piece1.hashCode()).isEqualTo(piece2.hashCode());
}
use of core.mino.Mino in project solution-finder by knewjade.
the class OriginalPieceTest method testEqualsDiffFieldHeight.
@Test
void testEqualsDiffFieldHeight() {
OriginalPiece piece1 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 10);
OriginalPiece piece2 = new OriginalPiece(new Mino(Piece.I, Rotate.Spawn), 3, 4, 5);
assertThat(piece1.equals(piece2)).isTrue();
}
Aggregations