option.tv.add(mod + " " + fa + " Back to enemy\n");
if(debug) option.tv.add(mod + " " + fa + " Back to enemy\n");
    private MoveOption[] thirdPass(CEntity self, ArrayList enemy_array) {        MoveOption[] move_array = self.pass.values().toArray(new MoveOption[0]);        self.pass.clear();        for (int j = 0; j < move_array.length; j++) {            MoveOption option =  move_array[j];            option.setState();            double adjustment = 0;            double temp_adjustment = 0;            for (int e = 0; e < enemy_array.size(); e++) { // for each enemy                Entity en = (Entity) enemy_array.get(e);                CEntity enemy = centities.get(en);                int current_range = self.current.getFinalCoords().distance(enemy.current.getFinalCoords());                int range = option.getFinalCoords().distance(enemy.current.getFinalCoords());                if (range > self.long_range) {                    temp_adjustment += (!(range < enemy.long_range) ? .5 : 1)                            * (1 + self.range_damages[self.range])                            * (Math.max(range - self.long_range - .5 * Math.max(self.jumpMP, .8 * self.runMP), 0));                }                if ((self.range == CEntity.RANGE_SHORT && (current_range > 5 || range > 9))                        || (self.range_damages[CEntity.RANGE_SHORT] < 4 && current_range > 10)) {                    temp_adjustment += ((enemy.range > CEntity.RANGE_SHORT) ? .5 : 1)                            * (Math.max(1 + self.range_damages[CEntity.RANGE_SHORT], 5))                            * Math.max(range - .5 * Math.max(self.jumpMP, .8 * self.runMP), 0);                } else if (self.range == CEntity.RANGE_MEDIUM) {                    temp_adjustment += ((current_range < 6 || current_range > 12) ? 1 : .25)                            * ((enemy.range > CEntity.RANGE_SHORT) ? .5 : 1)                            * (1 + self.range_damages[CEntity.RANGE_MEDIUM])                            * Math.abs(range - .5 * Math.max(self.jumpMP, .8 * self.runMP));                } else if (option.damage < .25 * self.range_damages[CEntity.RANGE_LONG]) {                    temp_adjustment += ((range < 10) ? .25 : 1)                            * (Math.max(1 + self.range_damages[CEntity.RANGE_LONG], 3))                            * (1 / (1 + option.threat));                }                adjustment += Math.sqrt(temp_adjustment * enemy.bv / self.bv);                //I would always like to face the opponent                if (!(enemy.getEntity().isProne() || enemy.getEntity().isImmobile())                        && CEntity.getThreatHitArc(option.getFinalCoords(),                                option.getFinalFacing(),                                enemy.getEntity().getPosition())                        != ToHitData.SIDE_FRONT) {                    int fa =                            CEntity.getFiringAngle(option.getFinalCoords(),                                    option.getFinalFacing(),                                    enemy.getEntity().getPosition());                    if (fa > 90 && fa < 270) {                        int distance = option.getFinalCoords().distance(enemy.current.getFinalCoords());                        double mod = 1;                        if (fa > 130 && fa < 240)                            mod = 2;                        //big formula that says don't do it                        mod *= ((Math.max(self.jumpMP, .8 * self.runMP) < 5) ? 2 : 1)                                * ((double) self.bv / (double) 50)                                * Math.sqrt(((double) self.bv) / enemy.bv)                                / ((double) distance / 6 + 1);                        option.self_threat += mod;                        option.tv.add(mod + " " + fa + " Back to enemy\n");                    }                }            }            adjustment *= self.overall_armor_percent * self.strategy.attack / enemy_array.size();            //fix for hiding in level 2 water            //To a greedy bot, it always seems nice to stay in here...            IHex h = game.getBoard().getHex(option.getFinalCoords());            if (h.containsTerrain(Terrains.WATER)                    && h.surface() > (self.getEntity().getElevation() + ((option.getFinalProne()) ? 0 : 1))) {                double mod = (self.getEntity().heat + option.getMovementheatBuildup() <= 7) ? 100 : 30;                adjustment += self.bv / mod;            }            //add them in now, then re-add them later            if (self.range > CEntity.RANGE_SHORT) {                int ele_dif =                        game.getBoard().getHex(option.getFinalCoords()).getElevation()                        - game.getBoard().getHex(self.current.getFinalCoords()).getElevation();                adjustment -= (Math.max(ele_dif, 0) + 1)                        * ((double) Compute.getTargetTerrainModifier(game, option.getEntity()).getValue() + 1);            }            //close the range if nothing else and healthy            if (option.damage < .25 * self.range_damages[self.range] && adjustment < self.range_damages[self.range]) {                for (int e = 0; e < enemy_array.size(); e++) {                    Entity en = (Entity) enemy_array.get(e);                    CEntity enemy = centities.get(en);                    int range = option.getFinalCoords().distance(enemy.current.getFinalCoords());                    if (range > 5)                        adjustment += Math.pow(self.overall_armor_percent, 2)                                * Math.sqrt((double) (range - 4) * enemy.bv / self.bv)                                / enemy_array.size();                }            }            if (option.damage < .25 * (1 + self.range_damages[self.range])) {                option.self_threat += 2 * adjustment;            } else if (option.damage < .5 * (1 + self.range_damages[self.range])) {                option.self_threat += adjustment;            }            option.tv.add(option.self_threat + " Initial Damage Adjustment " + "\n");        }        return move_array;    }