power: Saner power for items, ships, planes and land units
Items, ships, planes and land units all contribute to the power factor, which determines position on the power chart. Items are worth amount * item value * (0.5 + nation tech level / 1000.0) The item values aren't quite right: producing stuff can *hurt* your position on the power chart. Food, uw and rads are worth nothng. Reduce the value of oil, and give rads the same value as oil. Tweak value of iron and oil products so that production's power change is roughly zero around p.e. 0.9 (tech 110), except for construction materials, where it's zero at p.e. 0.5 (tech 0). Construction materials become less valuable, shells, guns and petrol become more valuable. Increase value of bars to roughly match the other changes. It may still be too low. Halve the value of civilians, and give the other half to uw. Results: old new change civ 100 50 / 2 mil 100 100 shell 80 125 * 1.5625 gun 400 950 * 2.375 pet 2 7 * 3.5 iron 10 10 dust 200 200 bar 1000 2500 * 2.5 food 0 0 oil 100 50 / 2 lcm 100 20 / 5 hcm 200 40 / 5 uw 0 50 new rad 0 50 new Ships, planes and land units are worth base value * effic/100.0 * (0.5 + unit tech level / 1000.0) For ships and land units, the base value is lcm/5.0 + hcm/5.0 Build cost is ignored, but lcms are valued twice as much "loose" ones (before this commit). Therefore, building stuff can change your position on the power chart in both directions, depending on the type of build. For planes, the base value is 20 * (0.5 + nation tech level / 1000.0) Build cost and materials are ignored, and tech is squared. This is plainly absurd. Unify to (power value of money and materials to build) * effic/100.0 This formula is chosen so that building stuff doesn't change your power factor. Bonus: it doesn't assume anything about possible build materials. For ships and land units, factoring in build cost overcompensates the discounted value of construction materials more often than not. Noteworthy changes for the stock game: ship type old new change ss slave ship 20 5.8 * 0.29 largest decrease cs cargo ship 20 7.8 * 0.39 ts trade ship 60 25.5 * 0.42 frg frigate 12 7.8 * 0.65 bb battleship 24 21.8 * 0.91 cal light carrier 22 30.4 * 1.38 can nuc carrier 30 84.6 * 2.82 largest increase land unit type old new change hat hvy artillery 12 9.6 * 0.8 largest decrease linf light infantry 2.4 3.32 * 1.38 cav cavalry 3 5.4 * 1.8 inf infantry 3 5.4 * 1.8 lar lt armor 3 6.4 * 2.13 com commando 3 15.4 * 5.13 eng engineer 3 30.4 * 10.13 meng mech engineer 3 45.4 * 15.13 largest increase For planes, the power value change depends on the type. Below a certain nation tech level, planes of this type become more valuable, above less. For the stock game, planes costing at most $1000 become less valuable at any nation tech level that can build them, and planes costing at least $1800 become more valuable at any practical tech level, i.e. under 400. Noteworthy planes: plane type new sam Sea Sparrow 2.1 least valuable f2 P-51 Mustang 4.34 lb TBD-1 Devastator 5.92 jf1 F-4 Phantom 10.6 tr C-56 Lodestar 10.78 jt C-141 Starlifter 15.86 jhb B-52 Strato-Fortress 33.54 ss KH-7 spysat 41.2 most valuable The old value is a flat 12 at nation tech level 100, 15 at tech level 250, and 18 at tech level 400. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
1307a3be6b
commit
ea5c8a6598
Notes:
Markus Armbruster
2017-08-14 20:30:51 +02:00
Partial fix for bug#133.
8 changed files with 276 additions and 256 deletions
|
@ -51,6 +51,8 @@ static void out5(double, int, int);
|
|||
static void gen_power(struct powstr *, int);
|
||||
static int powcmp(const void *, const void *);
|
||||
static void addtopow(short *, struct powstr *);
|
||||
static float empunit_power(int, int, short[], int);
|
||||
static float money_power(int);
|
||||
static float power_tech_factor(float);
|
||||
static float item_power(short[]);
|
||||
|
||||
|
@ -223,12 +225,14 @@ gen_power(struct powstr *powbuf, int save)
|
|||
int i;
|
||||
struct sctstr sect;
|
||||
struct plnstr plane;
|
||||
struct plchrstr *pcp;
|
||||
struct shpstr ship;
|
||||
struct mchrstr *mcp;
|
||||
struct lndstr land;
|
||||
struct lchrstr *lcp;
|
||||
struct nstr_item ni;
|
||||
struct nstr_sect ns;
|
||||
struct natstr *natp;
|
||||
float f;
|
||||
|
||||
player->btused += 10;
|
||||
memset(powbuf, 0, MAXNOC * sizeof(*powbuf));
|
||||
|
@ -246,39 +250,37 @@ gen_power(struct powstr *powbuf, int save)
|
|||
while (nxtitem(&ni, &land)) {
|
||||
if (land.lnd_own == 0)
|
||||
continue;
|
||||
lcp = &lchr[land.lnd_type];
|
||||
pow = &powbuf[land.lnd_own];
|
||||
addtopow(land.lnd_item, pow);
|
||||
f = (lchr[land.lnd_type].l_mat[I_LCM] / 10.0)
|
||||
* (land.lnd_effic / 100.0);
|
||||
f += (lchr[land.lnd_type].l_mat[I_HCM] / 10.0)
|
||||
* (land.lnd_effic / 100.0);
|
||||
upower[land.lnd_own] += f * 2 * power_tech_factor(land.lnd_tech);
|
||||
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
|
||||
upower[land.lnd_own] += empunit_power(land.lnd_effic,
|
||||
land.lnd_tech,
|
||||
lcp->l_mat, lcp->l_cost);
|
||||
if (!(lcp->l_flags & L_SPY))
|
||||
pow->p_units += 1.0;
|
||||
}
|
||||
snxtitem_all(&ni, EF_SHIP);
|
||||
while (nxtitem(&ni, &ship)) {
|
||||
if (ship.shp_own == 0)
|
||||
continue;
|
||||
mcp = &mchr[ship.shp_type];
|
||||
pow = &powbuf[ship.shp_own];
|
||||
addtopow(ship.shp_item, pow);
|
||||
f = (mchr[ship.shp_type].m_mat[I_LCM] / 10.0)
|
||||
* (ship.shp_effic / 100.0);
|
||||
f += (mchr[ship.shp_type].m_mat[I_HCM] / 10.0)
|
||||
* (ship.shp_effic / 100.0);
|
||||
upower[ship.shp_own] += f * 2 * power_tech_factor(ship.shp_tech);
|
||||
upower[ship.shp_own] += empunit_power(ship.shp_effic,
|
||||
ship.shp_tech,
|
||||
mcp->m_mat, mcp->m_cost);
|
||||
pow->p_ships += 1.0;
|
||||
}
|
||||
snxtitem_all(&ni, EF_PLANE);
|
||||
while (nxtitem(&ni, &plane)) {
|
||||
if (plane.pln_own == 0)
|
||||
continue;
|
||||
pcp = &plchr[plane.pln_type];
|
||||
pow = &powbuf[plane.pln_own];
|
||||
upower[plane.pln_own] += empunit_power(plane.pln_effic,
|
||||
plane.pln_tech,
|
||||
pcp->pl_mat, pcp->pl_cost);
|
||||
pow->p_planes += 1.0;
|
||||
natp = getnatp(plane.pln_own);
|
||||
f = 20 * (plane.pln_effic / 100.0) *
|
||||
(20 + natp->nat_level[NAT_TLEV]) / 500.0;
|
||||
upower[plane.pln_own] += f * power_tech_factor(plane.pln_tech);
|
||||
}
|
||||
for (i = 1; NULL != (natp = getnatp(i)); i++) {
|
||||
pow = &powbuf[i];
|
||||
|
@ -288,7 +290,7 @@ gen_power(struct powstr *powbuf, int save)
|
|||
continue;
|
||||
}
|
||||
pow->p_money = natp->nat_money;
|
||||
pow->p_power += pow->p_money / 100.;
|
||||
pow->p_power += money_power(natp->nat_money);
|
||||
|
||||
if (pow->p_sects > 0)
|
||||
pow->p_power += pow->p_sects
|
||||
|
@ -349,6 +351,19 @@ addtopow(short *vec, struct powstr *pow)
|
|||
pow->p_power += item_power(vec);
|
||||
}
|
||||
|
||||
static float
|
||||
empunit_power(int effic, int tech, short mat[], int cost)
|
||||
{
|
||||
return (item_power(mat) + money_power(cost)) * (effic / 100.0)
|
||||
* power_tech_factor(tech);
|
||||
}
|
||||
|
||||
static float
|
||||
money_power(int money)
|
||||
{
|
||||
return money / 100.0;
|
||||
}
|
||||
|
||||
static float
|
||||
power_tech_factor(float tech)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue