Search in sources :

Example 1 with Barracks

use of org.openbw.bwapi4j.unit.Barracks 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 2 with Barracks

use of org.openbw.bwapi4j.unit.Barracks 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)

Example 3 with Barracks

use of org.openbw.bwapi4j.unit.Barracks in project Ecgberht by Jabbo16.

the class ChooseMedic method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        else {
            for (ResearchingFacility u : gameState.UBs) {
                if (u instanceof Academy) {
                    int marine_count = 0;
                    if (!gameState.DBs.isEmpty()) {
                        marine_count = gameState.DBs.values().stream().mapToInt(Set::size).sum();
                    }
                    if (!gameState.MBs.isEmpty() && Util.countUnitTypeSelf(UnitType.Terran_Medic) * 4 < Util.countUnitTypeSelf(UnitType.Terran_Marine) - marine_count) {
                        for (Barracks b : gameState.MBs) {
                            if (!b.isTraining()) {
                                gameState.chosenUnit = UnitType.Terran_Medic;
                                gameState.chosenTrainingFacility = b;
                                return State.SUCCESS;
                            }
                        }
                    }
                    break;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Set(java.util.Set) Academy(org.openbw.bwapi4j.unit.Academy) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility) Barracks(org.openbw.bwapi4j.unit.Barracks)

Example 4 with Barracks

use of org.openbw.bwapi4j.unit.Barracks 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)

Example 5 with Barracks

use of org.openbw.bwapi4j.unit.Barracks in project Ecgberht by Jabbo16.

the class ChooseSCV method execute.

@Override
public State execute() {
    try {
        String strat = gameState.getStrat().name;
        if (strat.equals("ProxyBBS") || strat.equals("ProxyEightRax")) {
            boolean notTraining = false;
            for (Barracks b : gameState.MBs) {
                if (!b.isTraining()) {
                    notTraining = true;
                    break;
                }
            }
            if (notTraining)
                return State.FAILURE;
        }
        if (gameState.enemyRace == Race.Zerg && gameState.learningManager.isNaughty() && Util.countBuildingAll(UnitType.Terran_Barracks) > 0 && Util.countBuildingAll(UnitType.Terran_Bunker) < 1 && gameState.getCash().first < 150) {
            return State.FAILURE;
        }
        if (Util.countUnitTypeSelf(UnitType.Terran_SCV) <= 65 && Util.countUnitTypeSelf(UnitType.Terran_SCV) <= gameState.mineralsAssigned.size() * 2 + gameState.refineriesAssigned.size() * 3 + gameState.getStrat().extraSCVs && !gameState.CCs.isEmpty()) {
            for (Map.Entry<Base, CommandCenter> b : gameState.islandCCs.entrySet()) {
                if (!b.getValue().isTraining() && !b.getValue().isBuildingAddon() && Util.hasFreePatches(b.getKey())) {
                    gameState.chosenUnit = UnitType.Terran_SCV;
                    gameState.chosenTrainingFacility = b.getValue();
                    return State.SUCCESS;
                }
            }
            for (Map.Entry<Base, CommandCenter> b : gameState.CCs.entrySet()) {
                if (!b.getValue().isTraining() && !b.getValue().isBuildingAddon() && Util.hasFreePatches(b.getKey())) {
                    gameState.chosenUnit = UnitType.Terran_SCV;
                    gameState.chosenTrainingFacility = b.getValue();
                    return State.SUCCESS;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : CommandCenter(org.openbw.bwapi4j.unit.CommandCenter) Map(java.util.Map) Base(bwem.Base) Barracks(org.openbw.bwapi4j.unit.Barracks)

Aggregations

Barracks (org.openbw.bwapi4j.unit.Barracks)5 TilePosition (org.openbw.bwapi4j.TilePosition)2 UnitType (org.openbw.bwapi4j.type.UnitType)2 Building (org.openbw.bwapi4j.unit.Building)2 Base (bwem.Base)1 Map (java.util.Map)1 Set (java.util.Set)1 Player (org.openbw.bwapi4j.Player)1 Academy (org.openbw.bwapi4j.unit.Academy)1 CommandCenter (org.openbw.bwapi4j.unit.CommandCenter)1 Factory (org.openbw.bwapi4j.unit.Factory)1 Refinery (org.openbw.bwapi4j.unit.Refinery)1 ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)1 VespeneGeyser (org.openbw.bwapi4j.unit.VespeneGeyser)1