use of common.datastore.Result in project solution-finder by knewjade.
the class ResultPCFComparatorTest method compareDiffLastRotate.
@Test
void compareDiffLastRotate() throws Exception {
Result result1 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(0, 1, Rotate.Spawn), Piece.L);
Result result2 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(0, 1, Rotate.Reverse), Piece.L);
ResultPCFComparator comparator = new ResultPCFComparator();
// assert is not 0 & sign reversed
assertThat(comparator.compare(result1, result2) * comparator.compare(result2, result1)).as(result1.toString()).isLessThan(0);
}
use of common.datastore.Result in project solution-finder by knewjade.
the class ResultPCFComparatorTest method compareDiffLastX.
@Test
void compareDiffLastX() throws Exception {
Result result1 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(0, 1, Rotate.Spawn), Piece.L);
Result result2 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(1, 1, Rotate.Spawn), Piece.L);
ResultPCFComparator comparator = new ResultPCFComparator();
// assert is not 0 & sign reversed
assertThat(comparator.compare(result1, result2) * comparator.compare(result2, result1)).as(result1.toString()).isLessThan(0);
}
use of common.datastore.Result in project solution-finder by knewjade.
the class ResultPCFComparatorTest method compareDiffLastHold3.
@Test
void compareDiffLastHold3() throws Exception {
Result result1 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(0, 1, Rotate.Spawn), null);
Result result2 = new Result(DUMMY_ORDER, Piece.I, MinimalAction.create(0, 1, Rotate.Spawn), Piece.I);
ResultPCFComparator comparator = new ResultPCFComparator();
// assert is not 0 & sign reversed
assertThat(comparator.compare(result1, result2) * comparator.compare(result2, result1)).as(result1.toString()).isLessThan(0);
}
use of common.datastore.Result in project solution-finder by knewjade.
the class CheckmateNoHoldReuseTest method randomCheckmateWithJustBlock.
@Test
@LongTest
void randomCheckmateWithJustBlock() {
Randoms randoms = new Randoms();
for (int count = 0; count < 100; count++) {
int maxClearLine = randoms.nextInt(3, 8);
int maxDepth = randoms.nextIntClosed(5, 7);
List<Piece> pieces = randoms.blocks(maxDepth);
Field field = randoms.field(maxClearLine, maxDepth);
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
Stopwatch stopwatchNoUse = Stopwatch.createStoppedStopwatch();
Stopwatch stopwatchReuse = Stopwatch.createStoppedStopwatch();
for (int swap = 0; swap < 250; swap++) {
int index = randoms.nextInt(3, pieces.size());
Piece pop = pieces.remove(index);
pieces.add(pop);
stopwatchNoUse.start();
List<Result> result1 = checkmate.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchNoUse.stop();
stopwatchReuse.start();
List<Result> result2 = checkmateReuse.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchReuse.stop();
assertThat(result2).hasSameSizeAs(result1).containsAll(result1);
}
// 実行時間の比較がうまくいかないためskipする(戻り値のチェックのみ)
// assertThat(stopwatchReuse.getNanoAverageTime()).isLessThan(stopwatchNoUse.getNanoAverageTime());
}
}
use of common.datastore.Result in project solution-finder by knewjade.
the class CheckmateNoHoldReuseTest method randomCheckmateWithJustBlockTwice.
@Test
void randomCheckmateWithJustBlockTwice() {
Randoms randoms = new Randoms();
for (int count = 0; count < 100; count++) {
int maxClearLine = randoms.nextInt(3, 8);
int maxDepth = randoms.nextIntClosed(5, 7);
List<Piece> pieces = randoms.blocks(maxDepth);
Field field = randoms.field(maxClearLine, maxDepth);
Candidate<Action> candidate = new LockedCandidate(minoFactory, minoShifter, minoRotation, maxClearLine);
Stopwatch stopwatchNoUse = Stopwatch.createStoppedStopwatch();
Stopwatch stopwatchReuse1 = Stopwatch.createStoppedStopwatch();
Stopwatch stopwatchReuse2 = Stopwatch.createStoppedStopwatch();
for (int swap = 0; swap < 250; swap++) {
int index = randoms.nextInt(3, pieces.size());
Piece pop = pieces.remove(index);
pieces.add(pop);
stopwatchNoUse.start();
List<Result> result1 = checkmate.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchNoUse.stop();
stopwatchReuse1.start();
List<Result> result2 = checkmateReuse.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchReuse1.stop();
assertThat(result2).hasSameSizeAs(result1).containsAll(result1);
stopwatchReuse2.start();
List<Result> result3 = checkmateReuse.search(field, pieces, candidate, maxClearLine, maxDepth);
stopwatchReuse2.stop();
assertThat(result3).hasSameSizeAs(result1).containsAll(result1);
}
// 実行時間の比較がうまくいかないためskipする(戻り値のチェックのみ)
// assertThat(stopwatchReuse1.getNanoAverageTime()).isLessThan(stopwatchNoUse.getNanoAverageTime());
// assertThat(stopwatchReuse2.getNanoAverageTime()).isLessThan(stopwatchReuse1.getNanoAverageTime());
}
}
Aggregations