Search in sources :

Example 36 with TilePosition

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

the class ChooseExpand method execute.

@Override
public State execute() {
    try {
        String strat = gameState.getStrat().name;
        if (strat.equals("ProxyBBS") || strat.equals("ProxyEightRax") || ((strat.equals("JoyORush") || strat.equals("TheNitekat")) && gameState.getCash().first <= 550))
            return State.FAILURE;
        if (strat.equals("FullMech") && (gameState.myArmy.stream().noneMatch(u -> u.unit instanceof SiegeTank) || !gameState.getPlayer().hasResearched(TechType.Tank_Siege_Mode)) && gameState.firstExpand)
            return State.FAILURE;
        for (MutablePair<UnitType, TilePosition> w : gameState.workerBuild.values()) {
            if (w.first == UnitType.Terran_Command_Center)
                return State.FAILURE;
        }
        for (Building w : gameState.workerTask.values()) {
            if (w instanceof CommandCenter)
                return State.FAILURE;
        }
        if (strat.equals("PlasmaWraithHell") && Util.countUnitTypeSelf(UnitType.Terran_Command_Center) > 2) {
            return State.FAILURE;
        }
        if (gameState.iReallyWantToExpand || (gameState.getCash().first >= 550 && gameState.getArmySize() >= gameState.getStrat().armyForExpand) || (strat.equals("14CC") && gameState.supplyMan.getSupplyUsed() == 28)) {
            gameState.chosenToBuild = UnitType.Terran_Command_Center;
            return State.SUCCESS;
        }
        if ((strat.equals("BioGreedyFE") || strat.equals("MechGreedyFE") || strat.equals("BioMechGreedyFE") || strat.equals("PlasmaWraithHell")) && !gameState.MBs.isEmpty() && gameState.CCs.size() == 1) {
            gameState.chosenToBuild = UnitType.Terran_Command_Center;
            return State.SUCCESS;
        }
        int workers = gameState.workerIdle.size();
        for (Integer wt : gameState.mineralsAssigned.values()) workers += wt;
        if (gameState.mineralsAssigned.size() * 2 <= workers - 1 && gameState.getArmySize() >= gameState.getStrat().armyForExpand) {
            gameState.chosenToBuild = UnitType.Terran_Command_Center;
            return State.SUCCESS;
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Building(org.openbw.bwapi4j.unit.Building) UnitType(org.openbw.bwapi4j.type.UnitType) TilePosition(org.openbw.bwapi4j.TilePosition) CommandCenter(org.openbw.bwapi4j.unit.CommandCenter) SiegeTank(org.openbw.bwapi4j.unit.SiegeTank)

Example 37 with TilePosition

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

the class BwemExt method makeBoundingBoxIncludePoint.

// Enlarges the bounding box [topLeft, bottomRight] so that it includes A.
public static Pair<TilePosition, TilePosition> makeBoundingBoxIncludePoint(final TilePosition topLeft, final TilePosition bottomRight, final TilePosition point) {
    int topLeftX = topLeft.getX();
    int topLeftY = topLeft.getY();
    int bottomRightX = bottomRight.getX();
    int bottomRightY = bottomRight.getY();
    if (point.getX() < topLeftX)
        topLeftX = point.getX();
    if (point.getX() > bottomRightX)
        bottomRightX = point.getX();
    if (point.getY() < topLeftY)
        topLeftY = point.getY();
    if (point.getY() > bottomRightY)
        bottomRightY = point.getY();
    return new Pair<>(new TilePosition(topLeftX, topLeftY), new TilePosition(bottomRightX, bottomRightY));
}
Also used : TilePosition(org.openbw.bwapi4j.TilePosition)

Example 38 with TilePosition

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

the class CheckMineralWalkGoldRush method getCloserMineral.

private MineralPatch getCloserMineral(Map.Entry<SCV, MutablePair<UnitType, TilePosition>> entry) {
    double bestDist = Double.MAX_VALUE;
    MineralPatch closerMineral = null;
    SCV scv = entry.getKey();
    Position buildTarget = entry.getValue().second.toPosition();
    for (MineralPatch mineralPatch : gameState.walkingMinerals) {
        if (!mineralPatch.isVisible() || scv.getDistance(mineralPatch) <= 32 * 4)
            continue;
        double dist = mineralPatch.getDistance(buildTarget) * 1.2;
        if (dist > scv.getDistance(buildTarget))
            continue;
        Area mineralArea = gameState.bwem.getMap().getArea(mineralPatch.getTilePosition());
        Area workerArea = gameState.bwem.getMap().getArea(scv.getTilePosition());
        if (mineralPatch.equals(scv.getTargetUnit()) && mineralArea != null && mineralArea.equals(workerArea))
            continue;
        if (dist < bestDist) {
            bestDist = dist;
            closerMineral = mineralPatch;
        }
    }
    return closerMineral;
}
Also used : Area(bwem.Area) MineralPatch(org.openbw.bwapi4j.unit.MineralPatch) TilePosition(org.openbw.bwapi4j.TilePosition) Position(org.openbw.bwapi4j.Position) SCV(org.openbw.bwapi4j.unit.SCV)

Example 39 with TilePosition

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

the class ChooseBarracks method execute.

@Override
public State execute() {
    try {
        String strat = gameState.getStrat().name;
        if ((strat.equals("BioGreedyFE") || strat.equals("MechGreedyFE") || strat.equals("BioMechGreedyFE")) && Util.countBuildingAll(UnitType.Terran_Command_Center) == 1 && Util.countBuildingAll(UnitType.Terran_Barracks) > 1 && gameState.frameCount <= 24 * 240) {
            return State.FAILURE;
        }
        if (strat.equals("14CC") && Util.countBuildingAll(UnitType.Terran_Command_Center) < 2)
            return State.FAILURE;
        if (!gameState.getStrat().techToResearch.contains(TechType.Stim_Packs) && gameState.getStrat().raxPerCC == 1 && gameState.MBs.size() > 0) {
            return State.FAILURE;
        }
        if (gameState.learningManager.isNaughty() && gameState.enemyRace == Race.Zerg && Util.countBuildingAll(UnitType.Terran_Barracks) == 1 && Util.countBuildingAll(UnitType.Terran_Bunker) < 1) {
            return State.FAILURE;
        }
        if (!strat.equals("ProxyBBS") && !strat.equals("ProxyEightRax")) {
            if (!gameState.MBs.isEmpty() && Util.countBuildingAll(UnitType.Terran_Barracks) == gameState.getStrat().numRaxForAca && Util.countBuildingAll(UnitType.Terran_Academy) == 0) {
                return State.FAILURE;
            }
            if (Util.countBuildingAll(UnitType.Terran_Barracks) == gameState.getStrat().numRaxForAca && Util.countBuildingAll(UnitType.Terran_Refinery) == 0) {
                return State.FAILURE;
            }
        } else if (gameState.getPlayer().supplyUsed() < 16)
            return State.FAILURE;
        if (gameState.getStrat().buildUnits.contains(UnitType.Terran_Factory)) {
            int count = 0;
            boolean found = false;
            for (MutablePair<UnitType, TilePosition> w : gameState.workerBuild.values()) {
                if (w.first == UnitType.Terran_Barracks)
                    count++;
                if (w.first == UnitType.Terran_Factory)
                    found = true;
            }
            for (Building w : gameState.workerTask.values()) {
                if (w instanceof Barracks)
                    count++;
                if (w instanceof Factory)
                    found = true;
            }
            if (!gameState.Fs.isEmpty())
                found = true;
            if (count + gameState.MBs.size() > gameState.getStrat().numRaxForFac && !found)
                return State.FAILURE;
        }
        if (Util.countBuildingAll(UnitType.Terran_Academy) == 0 && Util.countBuildingAll(UnitType.Terran_Barracks) >= 2) {
            return State.FAILURE;
        }
        if (Util.countBuildingAll(UnitType.Terran_Barracks) == gameState.MBs.size() && gameState.getPlayer().minerals() >= 600) {
            gameState.chosenToBuild = UnitType.Terran_Barracks;
            return State.SUCCESS;
        }
        if (Util.countBuildingAll(UnitType.Terran_Barracks) < gameState.getStrat().raxPerCC * Util.getNumberCCs()) {
            gameState.chosenToBuild = UnitType.Terran_Barracks;
            return State.SUCCESS;
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Building(org.openbw.bwapi4j.unit.Building) UnitType(org.openbw.bwapi4j.type.UnitType) TilePosition(org.openbw.bwapi4j.TilePosition) Factory(org.openbw.bwapi4j.unit.Factory) Barracks(org.openbw.bwapi4j.unit.Barracks)

Example 40 with TilePosition

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

the class ChooseRefinery method execute.

@Override
public State execute() {
    try {
        String strat = gameState.getStrat().name;
        if (gameState.getPlayer().supplyUsed() < gameState.getStrat().supplyForFirstRefinery || gameState.getCash().second >= 300) {
            return State.FAILURE;
        }
        if ((strat.equals("BioGreedyFE") || strat.equals("FullBio") || strat.equals("FullBioFE")) && gameState.getCash().second >= 150) {
            return State.FAILURE;
        }
        if (gameState.getStrat().techToResearch.contains(TechType.Tank_Siege_Mode) && gameState.getCash().second >= 250) {
            return State.FAILURE;
        }
        if (gameState.refineriesAssigned.size() == 1) {
            boolean found = false;
            for (MutablePair<UnitType, TilePosition> w : gameState.workerBuild.values()) {
                if (w.first == UnitType.Terran_Barracks) {
                    found = true;
                    break;
                }
            }
            for (Building w : gameState.workerTask.values()) {
                if (w instanceof Barracks) {
                    found = true;
                    break;
                }
            }
            if (gameState.MBs.isEmpty() && !found)
                return State.FAILURE;
        }
        int count = 0;
        VespeneGeyser geyser = null;
        for (Entry<VespeneGeyser, Boolean> r : gameState.vespeneGeysers.entrySet()) {
            if (r.getValue()) {
                count++;
            } else
                geyser = r.getKey();
        }
        if (count == gameState.vespeneGeysers.size())
            return State.FAILURE;
        for (MutablePair<UnitType, TilePosition> w : gameState.workerBuild.values()) {
            if (w.first == UnitType.Terran_Refinery)
                return State.FAILURE;
        }
        for (Building w : gameState.workerTask.values()) {
            if (w instanceof Refinery && geyser != null && w.getTilePosition().equals(geyser.getTilePosition()))
                return State.FAILURE;
        }
        if ((strat.equals("BioGreedyFE") || strat.equals("MechGreedyFE") || strat.equals("BioMechGreedyFE")) && !gameState.refineriesAssigned.isEmpty() && Util.getNumberCCs() <= 2 && Util.countUnitTypeSelf(UnitType.Terran_SCV) < 30) {
            return State.FAILURE;
        }
        gameState.chosenToBuild = UnitType.Terran_Refinery;
        return State.SUCCESS;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Building(org.openbw.bwapi4j.unit.Building) VespeneGeyser(org.openbw.bwapi4j.unit.VespeneGeyser) Refinery(org.openbw.bwapi4j.unit.Refinery) Barracks(org.openbw.bwapi4j.unit.Barracks) UnitType(org.openbw.bwapi4j.type.UnitType) 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