? activity_target1.diff ? auto.rc ? base_assess_defense_unit1.diff ? bool_stdinhand1.diff.gz ? cr_entry_building.diff ? embass.gz ? mapview_updating.diff ? simple_ai_unit_type_iterate2.diff ? stats Index: ai/advmilitary.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v retrieving revision 1.98 diff -u -r1.98 advmilitary.c --- ai/advmilitary.c 2002/03/13 11:49:18 1.98 +++ ai/advmilitary.c 2002/03/15 08:01:00 @@ -45,11 +45,38 @@ } /********************************************************************** +Helper for assess_defense_quadratic and assess_defense_unit. +***********************************************************************/ +static int base_assess_defense_unit(struct city *pcity, struct unit *punit, + bool igwall, bool square, int wall_value) +{ + int v; + + if (!is_military_unit(punit)) { + return 0; + } + v = get_defense_power(punit) * punit->hp * + (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower); + if (is_ground_unit(punit)) { + v = (3 * v) / 2; + } + v /= POWER_DIVIDER; + if (square) { + v *= v; + } + if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) { + v *= wall_value; + v /= 10; + } + return v; +} + +/********************************************************************** Need positive feedback in m_a_c_b and bodyguard routines. -- Syela ***********************************************************************/ int assess_defense_quadratic(struct city *pcity) { - int v, def, l; + int def, l; const bool igwall = FALSE; /* this can be an arg if needed, but seems unneeded */ def = 0; for (l = 0; l * l < pcity->ai.wallvalue * 10; l++) { @@ -57,14 +84,7 @@ } /* wallvalue = 10, l = 10, wallvalue = 40, l = 20, wallvalue = 90, l = 30 */ unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, punit) - v = get_defense_power(punit) * punit->hp * - (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower); - if (is_ground_unit(punit)) v *= 1.5; - v /= 30; - if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) { - v *= l; v /= 10; - } - if (is_military_unit(punit)) def += v; + def += base_assess_defense_unit(pcity, punit, igwall, FALSE, l); unit_list_iterate_end; if (def > 1<<12) { freelog(LOG_VERBOSE, "Very large def in assess_defense_quadratic: %d in %s", @@ -79,17 +99,8 @@ **************************************************************************/ int assess_defense_unit(struct city *pcity, struct unit *punit, bool igwall) { - int v; - v = get_defense_power(punit) * punit->hp * - (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower); - if (is_ground_unit(punit)) v *= 1.5; - v /= 30; - v *= v; - if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) { - v *= pcity->ai.wallvalue; v /= 10; - } - if (is_military_unit(punit)) return(v); - return(0); + return base_assess_defense_unit(pcity, punit, igwall, TRUE, + pcity->ai.wallvalue); } /********************************************************************** @@ -449,8 +460,12 @@ else cur *= a; /* wanted to rank Legion > Catapult > Archer */ /* which we will do by munging f in the attacker want equations */ if (unit_type_flag(i, F_IGTER) && !def) cur *= 3; - if (unit_type_flag(i, F_PIKEMEN) && def) cur *= 1.5; - if (unit_types[i].move_type == LAND_MOVING && def) cur *= 1.5; + if (unit_type_flag(i, F_PIKEMEN) && def) { + cur = (3 * cur) / 2; + } + if (unit_types[i].move_type == LAND_MOVING && def) { + cur = (3 * cur) / 2; + } return(cur); } Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.187 diff -u -r1.187 aiunit.c --- ai/aiunit.c 2002/03/13 11:49:19 1.187 +++ ai/aiunit.c 2002/03/15 08:01:02 @@ -1118,7 +1118,9 @@ } d_val *= POWER_DIVIDER; d_val /= (unit_type(punit)->move_rate / SINGLE_MOVE); - if (unit_flag(punit, F_IGTER)) d_val /= 1.5; + if (unit_flag(punit, F_IGTER)) { + d_val = (d_val * 2) / 3; + } freelog(LOG_DEBUG, "%s@(%d,%d) looking for bodyguard, d_val=%d, my_val=%d", unit_type(punit)->name, punit->x, punit->y, d_val, Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.156 diff -u -r1.156 city.c --- common/city.c 2002/03/14 19:56:46 1.156 +++ common/city.c 2002/03/15 08:01:04 @@ -1427,7 +1427,9 @@ if (city_affected_by_wonder(pcity, B_HOOVER) || city_got_building(pcity, B_POWER) || city_got_building(pcity, B_HYDRO) || - city_got_building(pcity, B_NUCLEAR)) tmp *= 1.5; + city_got_building(pcity, B_NUCLEAR)) { + tmp = (3 * tmp) / 2; + } } pcity->shield_bonus = tmp + 100;