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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
Aggregations