Search in sources :

Example 6 with BW

use of org.openbw.bwapi4j.BW 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)));
}
Also used : BW(org.openbw.bwapi4j.BW) Position(org.openbw.bwapi4j.Position) WalkPosition(org.openbw.bwapi4j.WalkPosition) MutableInt(org.apache.commons.lang3.mutable.MutableInt) ChokePoint(bwem.ChokePoint) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BWEM_CPPathSamples(mockdata.BWEM_CPPathSamples) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with BW

use of org.openbw.bwapi4j.BW in project BWAPI4J by OpenBW.

the class TestDataExporter method main.

public static void main(String[] args) {
    TestDataExporter exporter = new TestDataExporter();
    exporter.bw = new BW(exporter);
    exporter.bw.startGame();
}
Also used : BW(org.openbw.bwapi4j.BW)

Aggregations

BW (org.openbw.bwapi4j.BW)7 Test (org.junit.Test)4 Ignore (org.junit.Ignore)3 BWEM_DummyData (mockdata.BWEM_DummyData)2 ChokePoint (bwem.ChokePoint)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 BWEM_CPPathSamples (mockdata.BWEM_CPPathSamples)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1 Position (org.openbw.bwapi4j.Position)1 WalkPosition (org.openbw.bwapi4j.WalkPosition)1