if (av.size() > 0){ getAimPoint(tm, av); }
    public void calculateFiringTurn() {        int first_entity = game.getFirstEntityNum();        int entity_num = first_entity;        int best_entity = first_entity;        int spin_mode = 0;        double max = java.lang.Double.MIN_VALUE;        int[] results = null;        ArrayList 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(entity_num);        } while (entity_num != first_entity && entity_num != -1);        java.util.Vector av = new java.util.Vector();        //maximum already selected (or default)        Entity en = game.getEntity(best_entity);        if (results != null) {            Entity primary_target = (Entity) game.getEntitiesVector().get(results[results.length - 1]);            TreeMap tm = new TreeMap(new AttackOption.Sorter(centities.get(primary_target)));            for (int i = 0; i < results.length - 1; i++) {                AttackOption a = (AttackOption) ((ArrayList) winner.get(i)).get(results[i]);                if (a.target != null) {                    a.target.expected_damage[a.toHit.getSideTable()] += a.value;                    a.target.hasTakenDamage = true;                    tm.put(a, a);                }            }            Iterator i = tm.values().iterator();            while (i.hasNext()) {                AttackOption a = (AttackOption) 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));                    Compute.getAmmoAdjDamage(game, new_attack);                }                av.add(new_attack);            }        }        switch (arc) {            case 1:                av.add(0, new TorsoTwistAction(en.getId(), (en.getFacing() + 5) % 6));                break;            case 2:                av.add(0, new TorsoTwistAction(en.getId(), (en.getFacing() + 1) % 6));                break;            case 3:                av.add(0, new TorsoTwistAction(en.getId(), (en.getFacing() + 3) % 6));                break;        }        sendAttackData(best_entity, av);    }