use of mockdata.BWEM_CPPathSamples in project BWAPI4J by OpenBW.
the class MapTest method Test_getPath_Lengths_Using_Original_Samples_LIVE.
@Ignore
@Test
public void Test_getPath_Lengths_Using_Original_Samples_LIVE() throws IOException, URISyntaxException {
this.bw = new BW(this);
this.bw.startGame();
int pathErrorsCount = 0;
int pathsCount = 0;
int differenceSum = 0;
final BWEM_CPPathSamples expectedPathSamples = new BWEM_CPPathSamples(this.bw.getBWMap().mapHash());
for (final BWEM_CPPathSamples.CPPSample expectedSample : expectedPathSamples.samples) {
final Position sampleStartPosition = expectedSample.startAndEnd.getLeft();
final Position sampleEndPosition = expectedSample.startAndEnd.getRight();
final int expectedPathLength = expectedSample.pathLength;
logger.debug("Testing: startPosition=" + sampleStartPosition.toString() + ", endPosition=" + sampleEndPosition.toString() + ", expectedPathLength=" + expectedPathLength);
++pathsCount;
try {
final MutableInt actualPathLength = new MutableInt();
this.bwemMap.getPath(sampleStartPosition, sampleEndPosition, actualPathLength);
final int difference = actualPathLength.intValue() - expectedPathLength;
if (difference != 0) {
differenceSum += difference;
logger.warn("Path lengths do not match: expectedPathLength=" + expectedPathLength + ", actualPathLength=" + actualPathLength + ", difference=" + difference);
}
} catch (final Exception e) {
logger.warn("Failed to find a path: path error: startPosition=" + sampleStartPosition.toString() + ", endPosition=" + sampleEndPosition.toString() + ", expectedPathLength=" + expectedPathLength);
++pathErrorsCount;
e.printStackTrace();
}
}
logger.info("Total # of Paths: " + pathsCount + ", # of Path errors: " + pathErrorsCount);
logger.info("Average difference: " + (differenceSum / (pathsCount - pathErrorsCount)));
}
Aggregations