Search in sources :

Example 6 with Player

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

the class ChooseMarine method execute.

@Override
public State execute() {
    try {
        if (!gameState.MBs.isEmpty()) {
            int multiplier = 2;
            String strat = gameState.getStrat().name;
            Player self = gameState.getPlayer();
            if (strat.equals("FullMech") || strat.equals("MechGreedyFE") || strat.equals("VultureRush"))
                multiplier = 15;
            if (!gameState.Fs.isEmpty() && (self.isResearching(TechType.Tank_Siege_Mode) || self.hasResearched(TechType.Tank_Siege_Mode)) && self.gas() >= UnitType.Terran_Siege_Tank_Tank_Mode.gasPrice() && self.minerals() <= 200) {
                if (Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Siege_Mode) + Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Tank_Mode) < Util.countUnitTypeSelf(UnitType.Terran_Marine) * multiplier) {
                    return State.FAILURE;
                }
            }
            if ((strat.equals("FullMech") || strat.equals("MechGreedyFE") || strat.equals("2PortWraith")) && Util.countUnitTypeSelf(UnitType.Terran_Marine) > (gameState.enemyRace == Race.Zerg ? 4 : 2) && !gameState.defense)
                return State.FAILURE;
            if (strat.equals("VultureRush") && Util.countUnitTypeSelf(UnitType.Terran_Marine) > 2 && !gameState.defense)
                return State.FAILURE;
            if (strat.equals("JoyORush") && Util.countBuildingAll(UnitType.Terran_Factory) < 2)
                return State.FAILURE;
            for (Barracks b : gameState.MBs) {
                if (!b.isTraining()) {
                    gameState.chosenUnit = UnitType.Terran_Marine;
                    gameState.chosenTrainingFacility = b;
                    return State.SUCCESS;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Player(org.openbw.bwapi4j.Player) Barracks(org.openbw.bwapi4j.unit.Barracks)

Aggregations

Player (org.openbw.bwapi4j.Player)6 Base (bwem.Base)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MapPrinterExample (bwem.example.MapPrinterExample)1 Agent (ecgberht.Agents.Agent)1 DropShipAgent (ecgberht.Agents.DropShipAgent)1 UnitInfo (ecgberht.UnitInfo)1 MutablePair (ecgberht.Util.MutablePair)1 TilePosition (org.openbw.bwapi4j.TilePosition)1 Academy (org.openbw.bwapi4j.unit.Academy)1 Barracks (org.openbw.bwapi4j.unit.Barracks)1 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)1 PlayerUnit (org.openbw.bwapi4j.unit.PlayerUnit)1 ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)1 Worker (org.openbw.bwapi4j.unit.Worker)1