Search in sources :

Example 11 with Position

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

the class CameraModule method isNearStartLocation.

private boolean isNearStartLocation(Position pos) {
    int distance = 1000;
    List<TilePosition> startLocations = game.getBWMap().getStartPositions();
    for (TilePosition it : startLocations) {
        Position startLocation = it.toPosition();
        // if the start position is not our own home, and the start position is closer than distance
        if (!isNearOwnStartLocation(startLocation) && startLocation.getDistance(pos) <= distance)
            return true;
    }
    return false;
}
Also used : TilePosition(org.openbw.bwapi4j.TilePosition) Position(org.openbw.bwapi4j.Position) TilePosition(org.openbw.bwapi4j.TilePosition)

Example 12 with Position

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

the class VesselAgent method hover.

private void hover() {
    Position attack = follow.attack;
    if (attack == null || !getGs().getGame().getBWMap().isValidPosition(attack))
        return;
    UtilMicro.move(unit, attack);
}
Also used : Position(org.openbw.bwapi4j.Position)

Example 13 with Position

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

the class VesselAgent method kite.

private void kite() {
    Set<UnitInfo> airThreats = airAttackers.stream().filter(u -> u.unitType == UnitType.Zerg_Scourge || u.unitType == UnitType.Zerg_Spore_Colony).collect(Collectors.toSet());
    if (!airThreats.isEmpty()) {
        Position kite = UtilMicro.kiteAway(unit, airThreats);
        if (kite != null) {
            UtilMicro.move(unit, kite);
            return;
        }
    }
    Position kite = UtilMicro.kiteAway(unit, airAttackers);
    if (kite == null || !getGs().getGame().getBWMap().isValidPosition(kite))
        return;
    UtilMicro.move(unit, kite);
}
Also used : Util(ecgberht.Util.Util) UnitInfo(ecgberht.UnitInfo) UtilMicro(ecgberht.Util.UtilMicro) Squad(ecgberht.Squad) Set(java.util.Set) Collectors(java.util.stream.Collectors) TreeSet(java.util.TreeSet) Objects(java.util.Objects) Ecgberht.getGs(ecgberht.Ecgberht.getGs) SimInfo(ecgberht.Simulation.SimInfo) org.openbw.bwapi4j.unit(org.openbw.bwapi4j.unit) org.openbw.bwapi4j.type(org.openbw.bwapi4j.type) Position(org.openbw.bwapi4j.Position) UnitInfo(ecgberht.UnitInfo) Position(org.openbw.bwapi4j.Position)

Example 14 with Position

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

the class VesselAgent method retreat.

private void retreat() {
    Position CC = getGs().getNearestCC(myUnit.getPosition(), true);
    if (CC != null)
        ((MobileUnit) myUnit).move(CC);
    else
        ((MobileUnit) myUnit).move(getGs().getPlayer().getStartLocation().toPosition());
    attackPos = null;
    attackUnit = null;
}
Also used : Position(org.openbw.bwapi4j.Position)

Example 15 with Position

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

the class WorkerScoutAgent method runAgent.

public boolean runAgent() {
    if (unit == null || !unit.exists() || unitInfo == null || !getGs().firstScout) {
        if (disrupter != null)
            getGs().disrupterBuilding = disrupter;
        getGs().firstScout = false;
        if (getGs().proxyBuilding != null && !getGs().proxyBuilding.isCompleted())
            getGs().proxyBuilding.cancelConstruction();
        return true;
    }
    if (status == Status.EXPLORE && getGs().getStrat().proxy && mySim.allies.stream().anyMatch(u -> u.unit instanceof Marine)) {
        getGs().myArmy.add(unitInfo);
        getGs().firstScout = false;
        if (getGs().proxyBuilding != null && !getGs().proxyBuilding.isCompleted())
            getGs().proxyBuilding.cancelConstruction();
        return true;
    }
    if (enemyBaseBorders.isEmpty())
        updateBorders();
    mySim = getGs().sim.getSimulation(unitInfo, SimInfo.SimType.GROUND);
    if (enemyNaturalIndex != -1 && (IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.EarlyPool || IntelligenceAgency.getEnemyStrat() == IntelligenceAgency.EnemyStrats.ZealotRush || getGs().learningManager.isNaughty() || getGs().basicCombatUnitsDetected(mySim.enemies) || IntelligenceAgency.getNumEnemyBases(getGs().getIH().enemy()) > 1)) {
        enemyBaseBorders.remove(enemyNaturalIndex);
        enemyNaturalIndex = -1;
        removedIndex = true;
    }
    status = chooseNewStatus();
    cancelDisrupter();
    switch(status) {
        case EXPLORE:
            followPerimeter();
            break;
        case DISRUPTING:
            disrupt();
            break;
        case PROXYING:
            proxy();
        case IDLE:
            break;
    }
    if (disrupter != null)
        getGs().getGame().getMapDrawer().drawTextMap(disrupter.getPosition().add(new Position(0, -16)), ColorUtil.formatText("BM!", ColorUtil.White));
    return false;
}
Also used : Result(org.bk.ass.path.Result) BuildingMap(ecgberht.BuildingMap) Util(ecgberht.Util.Util) ColorUtil(ecgberht.Util.ColorUtil) WalkPosition(org.openbw.bwapi4j.WalkPosition) Area(bwem.Area) UnitInfo(ecgberht.UnitInfo) UtilMicro(ecgberht.Util.UtilMicro) Set(java.util.Set) TilePosition(org.openbw.bwapi4j.TilePosition) IntelligenceAgency(ecgberht.IntelligenceAgency) ArrayList(java.util.ArrayList) Race(org.openbw.bwapi4j.type.Race) List(java.util.List) Ecgberht.getGs(ecgberht.Ecgberht.getGs) UnitType(org.openbw.bwapi4j.type.UnitType) SimInfo(ecgberht.Simulation.SimInfo) org.openbw.bwapi4j.unit(org.openbw.bwapi4j.unit) Order(org.openbw.bwapi4j.type.Order) Base(bwem.Base) Position(org.openbw.bwapi4j.Position) WalkPosition(org.openbw.bwapi4j.WalkPosition) TilePosition(org.openbw.bwapi4j.TilePosition) Position(org.openbw.bwapi4j.Position)

Aggregations

Position (org.openbw.bwapi4j.Position)55 TilePosition (org.openbw.bwapi4j.TilePosition)19 UnitInfo (ecgberht.UnitInfo)10 Worker (org.openbw.bwapi4j.unit.Worker)10 UnitType (org.openbw.bwapi4j.type.UnitType)9 SimInfo (ecgberht.Simulation.SimInfo)8 Util (ecgberht.Util.Util)8 WalkPosition (org.openbw.bwapi4j.WalkPosition)8 Ecgberht.getGs (ecgberht.Ecgberht.getGs)7 UtilMicro (ecgberht.Util.UtilMicro)7 org.openbw.bwapi4j.unit (org.openbw.bwapi4j.unit)7 Area (bwem.Area)6 Base (bwem.Base)6 Collectors (java.util.stream.Collectors)6 Order (org.openbw.bwapi4j.type.Order)6 java.util (java.util)5 WeaponType (org.openbw.bwapi4j.type.WeaponType)5 ArrayList (java.util.ArrayList)4 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)4 Squad (ecgberht.Squad)3