int spin_mode = 0;
double max = java.lang.Double.NEGATIVE_INFINITY;
int[] results = null;
ArrayList<ArrayList<AttackOption>> winner = null;
int arc = 0;
WeaponType spinner;
if (entity_num == -1) {
return;
}
do {
Entity en = game.getEntity(entity_num);
CEntity cen = centities.get(en);
GAAttack test = bestAttack(cen.current, null, 3);
if (test != null && test.getFittestChromosomesFitness() > max) {
max = test.getFittestChromosomesFitness();
results = test.getResultChromosome();
arc = test.getFiringArc();
best_entity = entity_num;
winner = test.getAttack();
}
entity_num = game.getNextEntityNum(getMyTurn(), entity_num);
} while (entity_num != first_entity && entity_num != -1);
Vector<EntityAction> av = new Vector<EntityAction>();
// maximum already selected (or default)
Entity en = game.getEntity(best_entity);
if (results != null) {
Entity primary_target = game.getEntitiesVector().get(results[results.length - 1]);
TreeSet<AttackOption> tm = new TreeSet<AttackOption>(new AttackOption.Sorter(centities
.get(primary_target)));
for (int i = 0; i < results.length - 1; i++) {
if (winner != null) {
AttackOption a = winner.get(i).get(results[i]);
if (a.target != null) {
a.target.expected_damage[a.toHit.getSideTable()] += a.value;
a.target.hasTakenDamage = true;
tm.add(a);
}
}
}
Iterator<AttackOption> i = tm.iterator();
while (i.hasNext()) {
AttackOption a = i.next();
WeaponAttackAction new_attack = new WeaponAttackAction(en.getId(), a.target
.getEntity().getId(), en.getEquipmentNum(a.weapon));
if (en.getEquipment(new_attack.getWeaponId()).getLinked() != null) {
spinner = (WeaponType) a.weapon.getType();
// If this is an ultra-cannon or rotary cannon, try to spin
// it up
if ((spinner.getAmmoType() == AmmoType.T_AC_ULTRA)
|| (spinner.getAmmoType() == AmmoType.T_AC_ULTRA_THB)
|| (spinner.getAmmoType() == AmmoType.T_AC_ROTARY)) {
spin_mode = Compute.spinUpCannon(game, new_attack);
super.sendModeChange(en.getId(), en.getEquipmentNum(a.weapon), spin_mode);
}
Mounted cur_ammo = en.getEquipment(new_attack.getWeaponId()).getLinked();
new_attack.setAmmoId(en.getEquipmentNum(cur_ammo));