Search in sources :

Example 46 with TilePosition

use of org.openbw.bwapi4j.TilePosition in project Ecgberht by Jabbo16.

the class AreaInitializer method computeBaseLocationScore.

private int computeBaseLocationScore(final TerrainData terrainData, final TilePosition location) {
    final TilePosition dimCC = UnitType.Terran_Command_Center.tileSize();
    int sumScore = 0;
    for (int dy = 0; dy < dimCC.getY(); ++dy) {
        for (int dx = 0; dx < dimCC.getX(); ++dx) {
            final Tile tile = terrainData.getTile(location.add(new TilePosition(dx, dy)), CheckMode.NO_CHECK);
            if (!tile.isBuildable()) {
                return -1;
            }
            if (tile.getInternalData() == -1) {
                // very reason of validateBaseLocation
                return -1;
            }
            if (!tile.getAreaId().equals(getId())) {
                return -1;
            }
            if (tile.getNeutral() instanceof StaticBuilding) {
                return -1;
            }
            sumScore += tile.getInternalData();
        }
    }
    return sumScore;
}
Also used : TilePosition(org.openbw.bwapi4j.TilePosition)

Aggregations

TilePosition (org.openbw.bwapi4j.TilePosition)46 ChokePoint (bwem.ChokePoint)13 Position (org.openbw.bwapi4j.Position)13 Area (bwem.Area)9 WalkPosition (org.openbw.bwapi4j.WalkPosition)8 Base (bwem.Base)7 MiniTile (bwem.tile.MiniTile)7 Tile (bwem.tile.Tile)7 ArrayList (java.util.ArrayList)7 UnitType (org.openbw.bwapi4j.type.UnitType)6 TileImpl (bwem.tile.TileImpl)4 Geyser (bwem.unit.Geyser)4 Mineral (bwem.unit.Mineral)4 Worker (org.openbw.bwapi4j.unit.Worker)4 MutablePair (ecgberht.Util.MutablePair)3 Building (org.openbw.bwapi4j.unit.Building)3 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)3 SCV (org.openbw.bwapi4j.unit.SCV)3 Area (bwem.area.Area)2 StaticBuilding (bwem.unit.StaticBuilding)2