private void computeRange(int arc,int[][] est_heat){
  double damage_by_bracket[]={0.0,0.0,0.0,0.0};
  double heat_by_bracket[]={0,0,0,0};
  long_range=MAX_RANGE - 1;
  int bracket_start, bracket_end;
  while ((damages[arc][long_range] == 0.0) && (long_range >= 4)) {
    long_range--;
  }
  rd_bracket=long_range / 4;
  long_range=3 * rd_bracket;
  bracket_start=0;
  bracket_end=rd_bracket;
  for (int cur_bracket=RANGE_SHORT; cur_bracket <= RANGE_LONG; cur_bracket++) {
switch (cur_bracket) {
case RANGE_SHORT:
      bracket_start=(entity instanceof Infantry ? 0 : 1);
    bracket_end=rd_bracket;
  break;
case RANGE_MEDIUM:
bracket_start=rd_bracket + 1;
bracket_end=2 * rd_bracket;
break;
case RANGE_LONG:
bracket_start=(2 * rd_bracket) + 1;
bracket_end=Math.min(long_range,MAX_RANGE - 1);
break;
}
for (int cur_range=bracket_start; cur_range <= bracket_end; cur_range++) {
damage_by_bracket[cur_bracket]+=damages[arc][cur_range];
damage_by_bracket[RANGE_ALL]+=damages[arc][cur_range];
heat_by_bracket[cur_bracket]+=est_heat[arc][cur_range];
heat_by_bracket[RANGE_ALL]+=est_heat[arc][cur_range];
}
}
for (int cur_range=RANGE_SHORT; cur_range <= RANGE_LONG; cur_range++) {
if ((damages[arc][0] != 0.0) && (cur_range == RANGE_SHORT)) {
damage_by_bracket[cur_range]/=(rd_bracket + 1);
heat_by_bracket[cur_range]/=(rd_bracket + 1);
}
 else {
damage_by_bracket[cur_range]/=rd_bracket;
heat_by_bracket[cur_range]/=rd_bracket;
}
}
damage_by_bracket[RANGE_ALL]/=long_range;
heat_by_bracket[RANGE_ALL]/=long_range;
range_damages=damage_by_bracket;
for (int cur_bracket=RANGE_SHORT; cur_bracket <= RANGE_ALL; cur_bracket++) {
heat_estimates[cur_bracket]=(int)heat_by_bracket[cur_bracket];
}
range=RANGE_SHORT;
for (int cur_bracket=RANGE_SHORT; cur_bracket <= RANGE_ALL; cur_bracket++) {
if (range_damages[cur_bracket] > range_damages[range]) {
range=cur_bracket;
}
}
heat_at_range=heat_estimates[range];
}

private void computeRange ( int arc , int [ ] [ ] est_heat ) { double damage_by_bracket [ ] = { 0.0 , 0.0 , 0.0 , 0.0 } ; double heat_by_bracket [ ] = { 0 , 0 , 0 , 0 } ; long_range = MAX_RANGE - 1 ; int bracket_start , bracket_end ; while ( ( damages [ arc ] [ long_range ] == 0.0 ) && ( long_range >= 4 ) ) { long_range -- ; } rd_bracket = long_range / 4 ; long_range = 3 * rd_bracket ; bracket_start = 0 ; bracket_end = rd_bracket ; for ( int cur_bracket = RANGE_SHORT ; cur_bracket <= RANGE_LONG ; cur_bracket ++ ) { switch ( cur_bracket ) { case RANGE_SHORT : bracket_start = ( entity instanceof Infantry ? 0 : 1 ) ; bracket_end = rd_bracket ; break ; case RANGE_MEDIUM : bracket_start = rd_bracket + 1 ; bracket_end = 2 * rd_bracket ; break ; case RANGE_LONG : bracket_start = ( 2 * rd_bracket ) + 1 ; bracket_end = Math . min ( long_range , MAX_RANGE - 1 ) ; break ; } for ( int cur_range = bracket_start ; cur_range <= bracket_end ; cur_range ++ ) { damage_by_bracket [ cur_bracket ] += damages [ arc ] [ cur_range ] ; damage_by_bracket [ RANGE_ALL ] += damages [ arc ] [ cur_range ] ; heat_by_bracket [ cur_bracket ] += est_heat [ arc ] [ cur_range ] ; heat_by_bracket [ RANGE_ALL ] += est_heat [ arc ] [ cur_range ] ; } } for ( int cur_range = RANGE_SHORT ; cur_range <= RANGE_LONG ; cur_range ++ ) { if ( ( damages [ arc ] [ 0 ] != 0.0 ) && ( cur_range == RANGE_SHORT ) ) { damage_by_bracket [ cur_range ] /= ( rd_bracket + 1 ) ; heat_by_bracket [ cur_range ] /= ( rd_bracket + 1 ) ; } else { damage_by_bracket [ cur_range ] /= rd_bracket ; heat_by_bracket [ cur_range ] /= rd_bracket ; } } damage_by_bracket [ RANGE_ALL ] /= long_range ; heat_by_bracket [ RANGE_ALL ] /= long_range ; range_damages = damage_by_bracket ; for ( int cur_bracket = RANGE_SHORT ; cur_bracket <= RANGE_ALL ; cur_bracket ++ ) { heat_estimates [ cur_bracket ] = ( int ) heat_by_bracket [ cur_bracket ] ; } range = RANGE_SHORT ; for ( int cur_bracket = RANGE_SHORT ; cur_bracket <= RANGE_ALL ; cur_bracket ++ ) { if ( range_damages [ cur_bracket ] > range_damages [ range ] ) { range = cur_bracket ; } } heat_at_range = heat_estimates [ range ] ; }
fills the centity damage and range brackets , plus the preferred range and the heat for that range .
