power: Make item power value configurable
Custom games may want to tweak how items contribute to the power factor, in particular when products are also customized. Add ichrstr member i_power and item selector power for that. "info power" doesn't reflect this change, yet. It'll be updated in the next commit. The current item power values are problematic. This will be addressed later. For straightforward configurations, reasonable item power values could perhaps be derived from the configuration automatically. However, this is surprisingly hard in the general case: since producing things should not decrease power, the efficiency of processing products into other products needs to be considered, and estimating these efficiencies can be difficult. Deities can create multiple products making the same item, or multiple sector types with the same product, but different process efficiency (sect-chr selector peffic). Providing differently efficient ways to make the same item can be reasonable when the sector types involved have different terrain. To average them, you'd need to know the map. The stock game has one example: gold mines produce dust with 100% process efficiency, mountains produce it with 75%. Mountains are normally rare enough not to matter. Level p.e. (product selectors nlmin, nllag) may have to be considered. In the stock game, level p.e. variations are minor, because it reaches 0.9 pretty quickly. In games where it doesn't, you might have to increase the power value of the product. Resources (sect selectors min, gold, fert, ocontent, uran) and resource depletion (product selectors nrndx and nrdep) further complicate things: you might want to increase the power value of products depending on unusually scarce resources, but you can't know what's scarce without understanding the map. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
5917841bfc
commit
8e187c566f
6 changed files with 55 additions and 57 deletions
|
@ -27,7 +27,7 @@
|
|||
* item.h: Definitions for item characteristics stuff
|
||||
*
|
||||
* Known contributors to this file:
|
||||
*
|
||||
* Markus Armbruster, 2004-2016
|
||||
*/
|
||||
|
||||
#ifndef ITEM_H
|
||||
|
@ -70,6 +70,7 @@ typedef enum {
|
|||
struct ichrstr {
|
||||
char i_mnem; /* usually the initial letter */
|
||||
i_type i_uid; /* index in ichr[] */
|
||||
int i_power; /* power value of 1000 items */
|
||||
int i_value; /* mortgage value */
|
||||
int i_sell; /* can this be sold? */
|
||||
int i_lbs; /* how hard to move */
|
||||
|
|
|
@ -358,17 +358,11 @@ power_tech_factor(float tech)
|
|||
static float
|
||||
item_power(short item[])
|
||||
{
|
||||
static float pow_denom[I_MAX + 1] = {
|
||||
10, 10, 12.5, 2.5, 500, 100, 5, 1, 0, 10, 10, 5, 0, 0
|
||||
};
|
||||
float p;
|
||||
int i;
|
||||
int pow, i;
|
||||
|
||||
p = 0.0;
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++) {
|
||||
if (pow_denom[i])
|
||||
p += item[i] / pow_denom[i];
|
||||
}
|
||||
pow = 0;
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++)
|
||||
pow += item[i] * ichr[i].i_power;
|
||||
|
||||
return p;
|
||||
return pow / 1000.0;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ struct castr ichr_ca[] = {
|
|||
{"uid", fldoff(i_uid), NSC_SITYPE(i_type), 0, NULL, EF_ITEM, 0},
|
||||
{"name", fldoff(i_name), NSC_STRING, 0, NULL, EF_BAD, 0},
|
||||
{"mnem", fldoff(i_mnem), NSC_STRINGY, 1, NULL, EF_BAD, NSC_CONST},
|
||||
{"power", fldoff(i_power), NSC_INT, 0, NULL, EF_BAD, 0},
|
||||
{"value", fldoff(i_value), NSC_INT, 0, NULL, EF_BAD, 0},
|
||||
{"sell", fldoff(i_sell), NSC_INT, 0, NULL, EF_BAD, 0},
|
||||
{"lbs", fldoff(i_lbs), NSC_INT, 0, NULL, EF_BAD, 0},
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
# item.config: Item characteristics
|
||||
#
|
||||
# Known contributors to this file:
|
||||
# Markus Armbruster, 2006-2012
|
||||
# Markus Armbruster, 2006-2016
|
||||
#
|
||||
# Derived from item.c; no known contributors.
|
||||
#
|
||||
|
@ -43,19 +43,19 @@
|
|||
# econfig key custom_tables.
|
||||
|
||||
config item # ineff norm ware urban bank
|
||||
uid mnem val sell lbs pkg(0) pkg(1) pkg(2) pkg(3) pkg(4) melt name
|
||||
0 "c" 1 0 1 1 10 10 10 10 4 "civilians"
|
||||
1 "m" 0 1 1 1 1 1 1 1 20 "military"
|
||||
2 "s" 5 1 1 1 1 10 1 1 80 "shells"
|
||||
3 "g" 60 1 10 1 1 10 1 1 100 "guns"
|
||||
4 "p" 4 1 1 1 1 10 1 1 50 "petrol"
|
||||
5 "i" 2 1 1 1 1 10 1 1 100 "iron ore"
|
||||
6 "d" 20 1 5 1 1 10 1 1 100 "dust (gold)"
|
||||
7 "b" 280 1 50 1 1 5 1 4 200 "bars of gold"
|
||||
8 "f" 0 1 1 1 1 10 1 1 2 "food"
|
||||
9 "o" 8 1 1 1 1 10 1 1 50 "oil"
|
||||
10 "l" 2 1 1 1 1 10 1 1 100 "light products"
|
||||
11 "h" 4 1 1 1 1 10 1 1 100 "heavy products"
|
||||
12 "u" 1 1 2 1 1 2 1 1 2 "uncompensated workers"
|
||||
13 "r" 150 1 8 1 1 10 1 1 1000 "radioactive materials"
|
||||
uid mnem pow val sell lbs pkg(0) pkg(1) pkg(2) pkg(3) pkg(4) melt name
|
||||
0 "c" 100 1 0 1 1 10 10 10 10 4 "civilians"
|
||||
1 "m" 100 0 1 1 1 1 1 1 1 20 "military"
|
||||
2 "s" 80 5 1 1 1 1 10 1 1 80 "shells"
|
||||
3 "g" 400 60 1 10 1 1 10 1 1 100 "guns"
|
||||
4 "p" 2 4 1 1 1 1 10 1 1 50 "petrol"
|
||||
5 "i" 10 2 1 1 1 1 10 1 1 100 "iron ore"
|
||||
6 "d" 200 20 1 5 1 1 10 1 1 100 "dust (gold)"
|
||||
7 "b" 1000 280 1 50 1 1 5 1 4 200 "bars of gold"
|
||||
8 "f" 0 0 1 1 1 1 10 1 1 2 "food"
|
||||
9 "o" 100 8 1 1 1 1 10 1 1 50 "oil"
|
||||
10 "l" 100 2 1 1 1 1 10 1 1 100 "light products"
|
||||
11 "h" 200 4 1 1 1 1 10 1 1 100 "heavy products"
|
||||
12 "u" 0 1 1 2 1 1 2 1 1 2 "uncompensated workers"
|
||||
13 "r" 0 150 1 8 1 1 10 1 1 1000 "radioactive materials"
|
||||
/config
|
||||
|
|
|
@ -86,6 +86,7 @@ tests/empdump/xundump-errors/fld-malstr:2: malformed string in field 1
|
|||
tests/empdump/xundump-errors/fld-many:2: too many fields, expected only 6
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'name' missing
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'mnem' missing
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'power' missing
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'value' missing
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'sell' missing
|
||||
tests/empdump/xundump-errors/fld-miss:2: field 'lbs' missing
|
||||
|
|
|
@ -952,12 +952,13 @@
|
|||
Play#0 output Play#0 1 "uid" 4 0 0 16
|
||||
Play#0 output Play#0 1 "name" 3 0 0 -1
|
||||
Play#0 output Play#0 1 "mnem" 13 4 1 -1
|
||||
Play#0 output Play#0 1 "power" 8 0 0 -1
|
||||
Play#0 output Play#0 1 "value" 8 0 0 -1
|
||||
Play#0 output Play#0 1 "sell" 8 0 0 -1
|
||||
Play#0 output Play#0 1 "lbs" 8 0 0 -1
|
||||
Play#0 output Play#0 1 "pkg" 8 0 5 -1
|
||||
Play#0 output Play#0 1 "melt_denom" 8 0 0 -1
|
||||
Play#0 output Play#0 1 /8
|
||||
Play#0 output Play#0 1 /9
|
||||
Play#0 output Play#0 6 0 640
|
||||
Play#0 input xdump meta 17
|
||||
Play#0 command xdump
|
||||
|
@ -1451,20 +1452,20 @@
|
|||
Play#0 input xdump item *
|
||||
Play#0 command xdump
|
||||
Play#0 output Play#0 1 XDUMP item 0
|
||||
Play#0 output Play#0 1 0 "civilians" "c" 1 0 1 1 10 10 10 10 4
|
||||
Play#0 output Play#0 1 1 "military" "m" 0 1 1 1 1 1 1 1 20
|
||||
Play#0 output Play#0 1 2 "shells" "s" 5 1 1 1 1 10 1 1 80
|
||||
Play#0 output Play#0 1 3 "guns" "g" 60 1 10 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 4 "petrol" "p" 4 1 1 1 1 10 1 1 50
|
||||
Play#0 output Play#0 1 5 "iron\\040ore" "i" 2 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 6 "dust\\040(gold)" "d" 20 1 5 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 7 "bars\\040of\\040gold" "b" 280 1 50 1 1 5 1 4 200
|
||||
Play#0 output Play#0 1 8 "food" "f" 0 1 1 1 1 10 1 1 2
|
||||
Play#0 output Play#0 1 9 "oil" "o" 8 1 1 1 1 10 1 1 50
|
||||
Play#0 output Play#0 1 10 "light\\040products" "l" 2 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 11 "heavy\\040products" "h" 4 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 12 "uncompensated\\040workers" "u" 1 1 2 1 1 2 1 1 2
|
||||
Play#0 output Play#0 1 13 "radioactive\\040materials" "r" 150 1 8 1 1 10 1 1 1000
|
||||
Play#0 output Play#0 1 0 "civilians" "c" 100 1 0 1 1 10 10 10 10 4
|
||||
Play#0 output Play#0 1 1 "military" "m" 100 0 1 1 1 1 1 1 1 20
|
||||
Play#0 output Play#0 1 2 "shells" "s" 80 5 1 1 1 1 10 1 1 80
|
||||
Play#0 output Play#0 1 3 "guns" "g" 400 60 1 10 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 4 "petrol" "p" 2 4 1 1 1 1 10 1 1 50
|
||||
Play#0 output Play#0 1 5 "iron\\040ore" "i" 10 2 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 6 "dust\\040(gold)" "d" 200 20 1 5 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 7 "bars\\040of\\040gold" "b" 1000 280 1 50 1 1 5 1 4 200
|
||||
Play#0 output Play#0 1 8 "food" "f" 0 0 1 1 1 1 10 1 1 2
|
||||
Play#0 output Play#0 1 9 "oil" "o" 100 8 1 1 1 1 10 1 1 50
|
||||
Play#0 output Play#0 1 10 "light\\040products" "l" 100 2 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 11 "heavy\\040products" "h" 200 4 1 1 1 1 10 1 1 100
|
||||
Play#0 output Play#0 1 12 "uncompensated\\040workers" "u" 0 1 1 2 1 1 2 1 1 2
|
||||
Play#0 output Play#0 1 13 "radioactive\\040materials" "r" 0 150 1 8 1 1 10 1 1 1000
|
||||
Play#0 output Play#0 1 /14
|
||||
Play#0 output Play#0 6 0 640
|
||||
Play#0 input xdump product *
|
||||
|
@ -2172,20 +2173,20 @@
|
|||
Play#1 input xdump item *
|
||||
Play#1 command xdump
|
||||
Play#1 output Play#1 1 XDUMP item 0
|
||||
Play#1 output Play#1 1 0 "civilians" "c" 1 0 1 1 10 10 10 10 4
|
||||
Play#1 output Play#1 1 1 "military" "m" 0 1 1 1 1 1 1 1 20
|
||||
Play#1 output Play#1 1 2 "shells" "s" 5 1 1 1 1 10 1 1 80
|
||||
Play#1 output Play#1 1 3 "guns" "g" 60 1 10 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 4 "petrol" "p" 4 1 1 1 1 10 1 1 50
|
||||
Play#1 output Play#1 1 5 "iron\\040ore" "i" 2 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 6 "dust\\040(gold)" "d" 20 1 5 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 7 "bars\\040of\\040gold" "b" 280 1 50 1 1 5 1 4 200
|
||||
Play#1 output Play#1 1 8 "food" "f" 0 1 1 1 1 10 1 1 2
|
||||
Play#1 output Play#1 1 9 "oil" "o" 8 1 1 1 1 10 1 1 50
|
||||
Play#1 output Play#1 1 10 "light\\040products" "l" 2 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 11 "heavy\\040products" "h" 4 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 12 "uncompensated\\040workers" "u" 1 1 2 1 1 2 1 1 2
|
||||
Play#1 output Play#1 1 13 "radioactive\\040materials" "r" 150 1 8 1 1 10 1 1 1000
|
||||
Play#1 output Play#1 1 0 "civilians" "c" 100 1 0 1 1 10 10 10 10 4
|
||||
Play#1 output Play#1 1 1 "military" "m" 100 0 1 1 1 1 1 1 1 20
|
||||
Play#1 output Play#1 1 2 "shells" "s" 80 5 1 1 1 1 10 1 1 80
|
||||
Play#1 output Play#1 1 3 "guns" "g" 400 60 1 10 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 4 "petrol" "p" 2 4 1 1 1 1 10 1 1 50
|
||||
Play#1 output Play#1 1 5 "iron\\040ore" "i" 10 2 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 6 "dust\\040(gold)" "d" 200 20 1 5 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 7 "bars\\040of\\040gold" "b" 1000 280 1 50 1 1 5 1 4 200
|
||||
Play#1 output Play#1 1 8 "food" "f" 0 0 1 1 1 1 10 1 1 2
|
||||
Play#1 output Play#1 1 9 "oil" "o" 100 8 1 1 1 1 10 1 1 50
|
||||
Play#1 output Play#1 1 10 "light\\040products" "l" 100 2 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 11 "heavy\\040products" "h" 200 4 1 1 1 1 10 1 1 100
|
||||
Play#1 output Play#1 1 12 "uncompensated\\040workers" "u" 0 1 1 2 1 1 2 1 1 2
|
||||
Play#1 output Play#1 1 13 "radioactive\\040materials" "r" 0 150 1 8 1 1 10 1 1 1000
|
||||
Play#1 output Play#1 1 /14
|
||||
Play#1 output Play#1 6 0 0
|
||||
Play#1 input xdump product *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue