use of com.sun.java.util.collections.Vector in project spoon by INRIA.
the class TestBot method bestAttack.
public GAAttack bestAttack(MoveOption es, CEntity target, int search_level) {
Entity en = es.getEntity();
int[] attacks = new int[3];
Vector front = new Vector();
Vector left = new Vector();
Vector right = new Vector();
GAAttack result = null;
int o_facing = en.getFacing();
for (Enumeration i = en.getWeapons(); i.hasMoreElements(); ) {
Mounted mw = (Mounted) i.nextElement();
Vector c = this.calculateWeaponAttacks(en, mw, true);
if (c.size() > 0) {
front.add(c);
attacks[0] = Math.max(attacks[0], c.size());
}
if (!es.getFinalProne() && en.canChangeSecondaryFacing()) {
en.setSecondaryFacing((o_facing + 5) % 6);
c = this.calculateWeaponAttacks(en, mw, true);
if (c.size() > 0) {
left.add(c);
attacks[1] = Math.max(attacks[1], c.size());
}
en.setSecondaryFacing((o_facing + 1) % 6);
c = this.calculateWeaponAttacks(en, mw, true);
if (c.size() > 0) {
right.add(c);
attacks[2] = Math.max(attacks[2], c.size());
}
} else {
attacks[1] = 0;
attacks[2] = 0;
}
en.setSecondaryFacing(o_facing);
}
Vector arcs = new Vector();
arcs.add(front);
if (!es.getFinalProne() && en.canChangeSecondaryFacing()) {
arcs.add(left);
arcs.add(right);
}
for (int i = 0; i < arcs.size(); i++) {
Vector v = (Vector) arcs.elementAt(i);
if (v.size() > 0) {
GAAttack test = new GAAttack(this, centities.get(en), v, Math.max((v.size() + attacks[i]) * search_level, 20 * search_level), 30 * search_level, en.isEnemyOf((Entity) getEntitiesOwned().get(0)));
test.setFiringArc(i);
test.evolve();
if (target != null) {
if (result == null || test.getDamageUtility(target) > result.getDamageUtility(target)) {
result = test;
}
} else if (result == null || test.getFittestChromosomesFitness() > result.getFittestChromosomesFitness()) {
result = test;
}
}
}
return result;
}
Aggregations