use of org.openbw.bwapi4j.unit.Factory in project Ecgberht by Jabbo16.
the class ChooseGoliath method execute.
@Override
public State execute() {
try {
if (gameState.UBs.stream().filter(unit -> unit instanceof Armory).count() < 1)
return State.FAILURE;
int count = 0;
for (Unit u : gameState.getGame().getUnits(gameState.getPlayer())) {
if (!u.exists())
continue;
if (u.getType() == UnitType.Terran_Goliath)
count++;
if (count >= gameState.maxGoliaths)
return State.FAILURE;
}
if (!gameState.Fs.isEmpty()) {
for (Factory b : gameState.Fs) {
if (!b.isTraining() && b.canTrain(UnitType.Terran_Goliath)) {
gameState.chosenUnit = UnitType.Terran_Goliath;
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.Factory in project Ecgberht by Jabbo16.
the class ChooseTank method execute.
@Override
public State execute() {
try {
if (!gameState.Fs.isEmpty()) {
if (gameState.getStrat().trainUnits.contains(UnitType.Terran_Wraith) && gameState.maxWraiths - Util.countUnitTypeSelf(UnitType.Terran_Wraith) > 0 && Math.random() * 10 <= 1) {
return State.FAILURE;
}
int multiplier = 2;
String strat = gameState.getStrat().name;
if (strat.equals("JoyORush") && gameState.tanksTrained == 3 && Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Tank_Mode) == 3)
return State.FAILURE;
if (strat.equals("FullMech") || strat.equals("MechGreedyFE"))
multiplier = 15;
if (Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Siege_Mode) + Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Tank_Mode) < Util.countUnitTypeSelf(UnitType.Terran_Marine) * multiplier) {
MutablePair<Integer, Integer> cash = gameState.getCash();
if (cash.second < (UnitType.Terran_Siege_Tank_Tank_Mode.gasPrice()))
return State.FAILURE;
for (Factory b : gameState.Fs) {
if (!b.isTraining() && b.canTrain(UnitType.Terran_Siege_Tank_Tank_Mode)) {
gameState.chosenUnit = UnitType.Terran_Siege_Tank_Tank_Mode;
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.Factory in project Ecgberht by Jabbo16.
the class ChooseMachineShop method execute.
@Override
public State execute() {
try {
if (gameState.getStrat().name.equals("VultureRush") && (gameState.Fs.size() < 2 || gameState.UBs.stream().anyMatch(u -> u instanceof MachineShop)))
return State.FAILURE;
if (gameState.getStrat().name.equals("TheNitekat") && (gameState.Fs.size() > 1 || gameState.UBs.stream().anyMatch(u -> u instanceof MachineShop)))
return State.FAILURE;
if (!gameState.Fs.isEmpty()) {
for (Factory c : gameState.Fs) {
if (!c.isTraining() && c.getAddon() == null) {
gameState.chosenBuildingAddon = c;
gameState.chosenAddon = UnitType.Terran_Machine_Shop;
return State.SUCCESS;
}
}
}
gameState.chosenBuildingAddon = null;
gameState.chosenAddon = null;
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
use of org.openbw.bwapi4j.unit.Factory 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.Factory in project Ecgberht by Jabbo16.
the class ChooseVulture method execute.
@Override
public State execute() {
try {
if (!gameState.Fs.isEmpty()) {
if (gameState.getStrat().name.equals("VultureRush") || Util.countUnitTypeSelf(UnitType.Terran_Vulture) * 2 <= Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Siege_Mode) + Util.countUnitTypeSelf(UnitType.Terran_Siege_Tank_Tank_Mode) + 2) {
for (Factory b : gameState.Fs) {
if (!b.isTraining() && b.canTrain(UnitType.Terran_Vulture)) {
gameState.chosenUnit = UnitType.Terran_Vulture;
gameState.chosenTrainingFacility = b;
return State.SUCCESS;
}
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
Aggregations