Search in sources :

Example 1 with Refinery

use of org.openbw.bwapi4j.unit.Refinery 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)1 UnitType (org.openbw.bwapi4j.type.UnitType)1 Barracks (org.openbw.bwapi4j.unit.Barracks)1 Building (org.openbw.bwapi4j.unit.Building)1 Refinery (org.openbw.bwapi4j.unit.Refinery)1 VespeneGeyser (org.openbw.bwapi4j.unit.VespeneGeyser)1