Skip to content

Commit

Permalink
Merge pull request #48 from Jabbo16/develop
Browse files Browse the repository at this point in the history
Latest develop build
  • Loading branch information
Jabbo16 authored Oct 1, 2019
2 parents d2228f1 + 081e243 commit 1ab9a15
Show file tree
Hide file tree
Showing 20 changed files with 699 additions and 644 deletions.
Binary file removed lib/ass-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file added lib/ass-1.1.jar
Binary file not shown.
13 changes: 5 additions & 8 deletions src/ecgberht/Agents/VultureAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ private UnitInfo getUnitToAttack(Set<UnitInfo> enemies) {
distB = distA;
}
}
if (chosen != null) return chosen;
return null;
return chosen;
}

private void retreat() {
Expand All @@ -157,18 +156,16 @@ private void getNewStatus() {
} else {
boolean meleeOnly = checkOnlyMelees();
if (!meleeOnly && getGs().sim.getSimulation(unitInfo, SimInfo.SimType.GROUND).lose) {
if (Util.isInOurBases(unitInfo)) {
status = Status.KITE;
} else status = Status.RETREAT;
status = Util.isInOurBases(unitInfo) ? Status.KITE : Status.RETREAT;
return;
}
if (status == Status.PATROL && actualFrame - lastPatrolFrame > 5) {
status = Status.COMBAT;
return;
}
int cd = unit.getGroundWeapon().cooldown();
UnitInfo closestAttacker = Util.getClosestUnit(unitInfo, mySim.enemies);
if (closestAttacker != null && (cd != 0 || unitInfo.getDistance(closestAttacker) < unit.getGroundWeaponMaxRange() * 0.6)) {
UnitInfo closestAttacker = Util.getClosestUnit(unitInfo, mySim.enemies, true);
if (closestAttacker != null && (cd != 0 || unitInfo.getDistance(closestAttacker) < unitInfo.groundRange * 0.6)) {
status = Status.KITE;
return;
}
Expand Down Expand Up @@ -269,7 +266,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(unit);
return Objects.hash(unit.getId());
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/ecgberht/Agents/WraithAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean runAgent() { // TODO improve
UtilMicro.move(unit, kitePos);
return false;
}
} else if (harassed != null && myWeapon.maxRange() >= unitInfo.getDistance(harassed)) {
} else if (harassed != null && unitInfo.getDistance(harassed) <= myWeapon.maxRange()) {
UtilMicro.attack(unitInfo, harassed);
} else UtilMicro.attack(unitInfo, closestThreat);
return false;
Expand Down Expand Up @@ -116,8 +116,7 @@ private UnitInfo chooseHarassTarget(Set<UnitInfo> mainTargets) {
maxScore = score;
}
}
if (chosen != null) return chosen;
return null;
return chosen;
}

@Override
Expand All @@ -130,7 +129,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(unit);
return Objects.hash(unit.getId());
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions src/ecgberht/BehaviourTrees/Training/ChooseFireBat.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ public ChooseFireBat(String name, GameState gh) {
@Override
public State execute() {
try {
if (gameState.enemyRace != Race.Zerg) return State.FAILURE;
if (gameState.UBs.isEmpty()) return State.FAILURE;
else if (Util.countUnitTypeSelf(UnitType.Terran_Marine) >= 4) {
if (gameState.enemyRace != Race.Zerg || gameState.UBs.isEmpty()) return State.FAILURE;
if (Util.countUnitTypeSelf(UnitType.Terran_Marine) >= 4) {
for (ResearchingFacility r : gameState.UBs) {
if (r instanceof Academy) {
int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public State execute() {
}*/

// Testing vessels
if (Util.countUnitTypeSelf(UnitType.Terran_Science_Vessel) > 2 || gameState.workerMining.isEmpty())
if (Util.countUnitTypeSelf(UnitType.Terran_Science_Vessel) > gameState.maxVessels || gameState.workerMining.isEmpty())
return State.FAILURE;
if (Util.countUnitTypeSelf(UnitType.Terran_Science_Vessel) > 0 && !gameState.needToAttack())
return State.FAILURE;
Expand All @@ -81,7 +81,7 @@ public State execute() {
if (!tower || !science) return State.FAILURE;
for (Starport s : gameState.Ps) {
if (s.getAddon() != null && s.getAddon().isCompleted() && !s.isTraining()) {
if (gameState.getCash().second < UnitType.Terran_Science_Vessel.gasPrice()
if (strat.contains("Bio") && gameState.getCash().second < UnitType.Terran_Science_Vessel.gasPrice()
&& gameState.getCash().first >= UnitType.Terran_Science_Vessel.mineralPrice() + 50) {
for (Barracks b : gameState.MBs) {
if (!b.isTraining()) {
Expand Down
8 changes: 3 additions & 5 deletions src/ecgberht/Cartographer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ecgberht;

import org.bk.ass.path.Jps;
import org.bk.ass.path.Map;
import org.bk.ass.path.PPMap;
import org.bk.ass.path.Position;
import org.bk.ass.path.Result;
import org.openbw.bwapi4j.TilePosition;
Expand Down Expand Up @@ -45,13 +45,11 @@ private void initWalkableGrids() {
tileWalkableGrid[ii][jj] = getGs().getGame().getBWMap().isWalkable(ii * 4, jj * 4);
}
}
mapJPS = new Jps(Map.fromBooleanArray(walkableGrid));
mapJPSTile = new Jps(Map.fromBooleanArray(tileWalkableGrid));
mapJPS = new Jps(PPMap.fromBooleanArray(walkableGrid));
mapJPSTile = new Jps(PPMap.fromBooleanArray(tileWalkableGrid));
}

enum Resolution {
TilePosition, WalkPosition
}

;
}
3 changes: 3 additions & 0 deletions src/ecgberht/DebugManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ private void debugText(GameState gameState) {
mapDrawer.drawTextScreen(320, 50, ColorUtil.formatText("I want to train: " + gameState.chosenUnit.toString(), ColorUtil.White));
mapDrawer.drawTextScreen(320, 65, ColorUtil.formatText("I want to build: " + gameState.chosenToBuild.toString(), ColorUtil.White));
mapDrawer.drawTextScreen(320, 80, ColorUtil.formatText("Max_Goliaths: " + gameState.maxGoliaths, ColorUtil.White));
mapDrawer.drawTextScreen(320, 95, ColorUtil.formatText("Max_Vessels: " + gameState.maxVessels, ColorUtil.White));
if (gameState.enemyRace == Race.Zerg)
mapDrawer.drawTextScreen(320, 110, ColorUtil.formatText("Max_Firebats: " + gameState.maxBats, ColorUtil.White));
if (gameState.ih.allies().size() + gameState.ih.enemies().size() == 1) {
mapDrawer.drawTextScreen(10, 5,
ColorUtil.formatText(gameState.ih.self().getName(), ColorUtil.getColor(gameState.ih.self().getColor())) +
Expand Down
55 changes: 24 additions & 31 deletions src/ecgberht/Ecgberht.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ public void onStart() {
gs.fortressSpecialBLs.put(b, gs.getMineralWalkPatchesFortress(b));
gs.BLs.add(b);

} //else if (b.getArea().getAccessibleNeighbors().isEmpty()) gs.islandBases.add(b); // Island expansions disabled for now
} else if (b.getArea().getAccessibleNeighbors().isEmpty())
gs.islandBases.add(b); // Island expansions re-enabled
else gs.BLs.add(b);
}
gs.initBlockingMinerals();
Expand Down Expand Up @@ -412,7 +413,6 @@ public void onFrame() {
} else {
path = gs.silentCartographer.getWalkablePath(self.getStartLocation().toWalkPosition(), gs.enemyMainBase.getLocation().toWalkPosition());
}

} else {
for (org.bk.ass.path.Position p : path.path) {
Position pos = new WalkPosition(p.x, p.y).toPosition();
Expand Down Expand Up @@ -702,26 +702,24 @@ else if (gs.getStrat().name.equals("BioMechGreedyFE") && Util.getNumberCCs() < 3
}
}
}
} else if (type.isWorker()) gs.workerIdle.add((Worker) arg0);
else if (type == UnitType.Terran_Vulture && !gs.getStrat().name.equals("TheNitekat"))
gs.agents.put(arg0, new VultureAgent(arg0));
else if (type == UnitType.Terran_Dropship) {
DropShipAgent d = new DropShipAgent(arg0);
gs.agents.put(arg0, d);
} else if (type == UnitType.Terran_Science_Vessel) {
VesselAgent v = new VesselAgent(arg0);
gs.agents.put(arg0, v);
} else if (type == UnitType.Terran_Wraith) {
if (!gs.getStrat().name.equals("PlasmaWraithHell")) {
String name = gs.pickShipName();
gs.agents.put(arg0, new WraithAgent(arg0, name));
}
} else {
if (type.isWorker()) gs.workerIdle.add((Worker) arg0);
else if (type == UnitType.Terran_Vulture && !gs.getStrat().name.equals("TheNitekat"))
gs.agents.put(arg0, new VultureAgent(arg0));
else if (type == UnitType.Terran_Dropship) {
DropShipAgent d = new DropShipAgent(arg0);
gs.agents.put(arg0, d);
} else if (type == UnitType.Terran_Science_Vessel) {
VesselAgent v = new VesselAgent(arg0);
gs.agents.put(arg0, v);
} else if (type == UnitType.Terran_Wraith) {
if (!gs.getStrat().name.equals("PlasmaWraithHell")) {
String name = gs.pickShipName();
gs.agents.put(arg0, new WraithAgent(arg0, name));
}
} else {
gs.myArmy.add(gs.unitStorage.getAllyUnits().get(arg0));
if (gs.enemyMainBase != null && gs.silentCartographer.mapCenter.getDistance(gs.enemyMainBase.getLocation()) < arg0.getTilePosition().getDistance(gs.enemyMainBase.getLocation())) {
((MobileUnit) arg0).move(gs.silentCartographer.mapCenter.toPosition());
}
gs.myArmy.add(gs.unitStorage.getAllyUnits().get(arg0));
if (gs.enemyMainBase != null && gs.silentCartographer.mapCenter.getDistance(gs.enemyMainBase.getLocation()) < arg0.getTilePosition().getDistance(gs.enemyMainBase.getLocation())) {
((MobileUnit) arg0).move(gs.silentCartographer.mapCenter.toPosition());
}
}
}
Expand Down Expand Up @@ -877,9 +875,7 @@ public void onUnitDestroy(Unit arg0) {
for (CommandCenter u : gs.CCs.values()) {
if (u.equals(arg0)) {
gs.removeResources(arg0);
if (u.getAddon() != null) {
gs.CSs.remove(u.getAddon());
}
if (u.getAddon() != null) gs.CSs.remove(u.getAddon());
if (bwem.getMap().getArea(arg0.getTilePosition()).equals(gs.naturalArea)) {
gs.defendPosition = gs.mainChoke.getCenter().toPosition();
}
Expand Down Expand Up @@ -938,13 +934,10 @@ public void onUnitDestroy(Unit arg0) {
}
}
gs.testMap = gs.map.clone();
} else if (type == UnitType.Terran_Vulture) {
gs.agents.remove(arg0);
} else if (type == UnitType.Terran_Dropship) {
gs.agents.remove(arg0);
} else if (type == UnitType.Terran_Science_Vessel) {
gs.agents.remove(arg0);
} else if (type == UnitType.Terran_Wraith && !gs.getStrat().name.equals("PlasmaWraithHell") && gs.agents.containsKey(arg0)) {
} else if (type == UnitType.Terran_Vulture) gs.agents.remove(arg0);
else if (type == UnitType.Terran_Dropship) gs.agents.remove(arg0);
else if (type == UnitType.Terran_Science_Vessel) gs.agents.remove(arg0);
else if (type == UnitType.Terran_Wraith && !gs.getStrat().name.equals("PlasmaWraithHell") && gs.agents.containsKey(arg0)) {
String wraith = ((WraithAgent) gs.agents.get(arg0)).name;
gs.shipNames.add(wraith);
gs.agents.remove(arg0);
Expand Down
63 changes: 35 additions & 28 deletions src/ecgberht/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public class GameState {
public Building proxyBuilding = null;
public BW bw;
public Worker naughtySCV = null;
public int maxVessels = 0;
InteractionHandler ih;
public BWEM bwem;
protected Player self;
Expand Down Expand Up @@ -1135,35 +1136,41 @@ public boolean basicCombatUnitsDetected(Set<UnitInfo> units) {
}

void vespeneManager() {
int workersAtGas = workerGas.keySet().size();
int refineries = refineriesAssigned.size();
if (getCash().second >= 200) {
int workersNeeded;
if (getStrat().techToResearch.contains(TechType.Stim_Packs) && !getStrat().techToResearch.contains(TechType.Tank_Siege_Mode)) {
workersNeeded = refineries;
getStrat().workerGas = 1;
} else {
workersNeeded = 2 * refineries;
getStrat().workerGas = 2;
}
if (workersAtGas > workersNeeded) {
Iterator<Entry<Worker, GasMiningFacility>> iterGas = workerGas.entrySet().iterator();
while (iterGas.hasNext()) {
Entry<Worker, GasMiningFacility> w = iterGas.next();
if (w.getKey().getOrder() == Order.HarvestGas) continue;
workerIdle.add(w.getKey());
if (w.getKey().isCarryingGas()) {
w.getKey().returnCargo();
w.getKey().stop(true);
} else w.getKey().stop(false);
refineriesAssigned.put(w.getValue(), refineriesAssigned.get(w.getValue()) - 1);
iterGas.remove();
workersAtGas--;
if (workersNeeded == workersAtGas) break;
try {
int workersAtGas = workerGas.keySet().size();
int refineries = refineriesAssigned.size();
if (refineries == 0) return;
if (getCash().second >= 200) {
int workersNeeded;
if (getStrat().techToResearch.contains(TechType.Stim_Packs) && !getStrat().techToResearch.contains(TechType.Tank_Siege_Mode)) {
workersNeeded = refineries;
getStrat().workerGas = 1;
} else {
workersNeeded = 2 * refineries;
getStrat().workerGas = 2;
}
}
} else if (getCash().second < 100 && getStrat().workerGas < 3 && workersAtGas / refineries == getStrat().workerGas)
getStrat().workerGas++;
if (workersAtGas > workersNeeded) {
Iterator<Entry<Worker, GasMiningFacility>> iterGas = workerGas.entrySet().iterator();
while (iterGas.hasNext()) {
Entry<Worker, GasMiningFacility> w = iterGas.next();
if (w.getKey().getOrder() == Order.HarvestGas) continue;
workerIdle.add(w.getKey());
if (w.getKey().isCarryingGas()) {
w.getKey().returnCargo();
w.getKey().stop(true);
} else w.getKey().stop(false);
refineriesAssigned.put(w.getValue(), refineriesAssigned.get(w.getValue()) - 1);
iterGas.remove();
workersAtGas--;
if (workersNeeded == workersAtGas) break;
}
}
} else if (getCash().second < 100 && getStrat().workerGas < 3 && workersAtGas / refineries == getStrat().workerGas)
getStrat().workerGas++;
} catch (Exception e) {
System.err.println("vespeneManager exception");
e.printStackTrace();
}
}

public boolean isGoingToExpand() {
Expand Down
Loading

0 comments on commit 1ab9a15

Please sign in to comment.