use of jfap.JFAPUnit in project Ecgberht by Jabbo16.
the class GameState method simulateDefenseBattle.
public Pair<Boolean, Boolean> simulateDefenseBattle(Set<Unit> friends, Set<Unit> enemies, int frames, boolean bunker) {
simulator.clear();
Pair<Boolean, Boolean> result = new Pair<>(true, false);
for (Unit u : friends) {
simulator.addUnitPlayer1(new JFAPUnit(u));
}
for (Unit u : enemies) {
simulator.addUnitPlayer2(new JFAPUnit(u));
}
Pair<Integer, Integer> presim_scores = simulator.playerScores();
// int presim_my_unit_count = simulator.getState().first.size();
// int presim_enemy_unit_count = simulator.getState().second.size();
simulator.simulate(frames);
// int postsim_my_unit_count = simulator.getState().first.size();
// int postsim_enemy_unit_count = simulator.getState().second.size();
Pair<Integer, Integer> postsim_scores = simulator.playerScores();
// int my_losses = presim_my_unit_count - postsim_my_unit_count;
// int enemy_losses = presim_enemy_unit_count - postsim_enemy_unit_count;
int my_score_diff = presim_scores.first - postsim_scores.first;
int enemy_score_diff = presim_scores.second - postsim_scores.second;
// System.out.println("-----------------------");
if (enemy_score_diff * 1.5 < my_score_diff) {
result.first = false;
}
if (bunker) {
boolean bunkerDead = true;
for (JFAPUnit unit : simulator.getState().first) {
if (unit.unitType == UnitType.Terran_Bunker) {
bunkerDead = false;
break;
}
}
if (bunkerDead) {
result.second = true;
}
}
return result;
}
use of jfap.JFAPUnit in project Ecgberht by Jabbo16.
the class GameState method simulateHarass.
public boolean simulateHarass(Unit harasser, List<Unit> enemies, int frames) {
simulator.clear();
simulator.addUnitPlayer1(new JFAPUnit(harasser));
for (Unit u : enemies) {
simulator.addUnitPlayer2(new JFAPUnit(u));
}
int preSimFriendlyUnitCount = simulator.getState().first.size();
simulator.simulate(frames);
int postSimFriendlyUnitCount = simulator.getState().first.size();
int myLosses = preSimFriendlyUnitCount - postSimFriendlyUnitCount;
if (myLosses > 0) {
return false;
}
return true;
}
use of jfap.JFAPUnit in project Ecgberht by Jabbo16.
the class GameState method simulateHarass.
public boolean simulateHarass(Unit harasser, Set<Unit> enemies, int frames) {
simulator.clear();
simulator.addUnitPlayer1(new JFAPUnit(harasser));
for (Unit u : enemies) {
simulator.addUnitPlayer2(new JFAPUnit(u));
}
int preSimFriendlyUnitCount = simulator.getState().first.size();
simulator.simulate(frames);
int postSimFriendlyUnitCount = simulator.getState().first.size();
int myLosses = preSimFriendlyUnitCount - postSimFriendlyUnitCount;
if (myLosses > 0) {
return false;
}
return true;
}
Aggregations