neweff production: Consider insufficient food
newe() and prod() duplicate parts of the update's do_feed(), except they round babies down instead of randomly, to get a stable, conservative forecast. Unlike the update, they assume sufficient food. Inaccurate for sectors that are going to starve or have suboptimal population growth. Not documented. Has always been that way. Eliminate the undocumented assumption by replacing the duplicate code by a call of do_feed(). Add a suitable parameter to do_feed() to preserve the different rounding. The update test shows the improvement. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
43fc32a365
commit
41a2f7d1df
6 changed files with 40 additions and 56 deletions
|
@ -89,13 +89,10 @@ prod(void)
|
|||
char cmnem[MAXPRCON];
|
||||
int cuse[MAXPRCON], cmax[MAXPRCON];
|
||||
int lcms, hcms;
|
||||
int civs;
|
||||
int uws;
|
||||
int bwork;
|
||||
int twork;
|
||||
int type;
|
||||
int eff;
|
||||
int maxworkers;
|
||||
char mnem;
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
|
@ -106,20 +103,13 @@ prod(void)
|
|||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
|
||||
civs = (1.0 + obrate * etu_per_update) * sect.sct_item[I_CIVIL];
|
||||
uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
|
||||
natp = getnatp(sect.sct_own);
|
||||
maxworkers = max_workers(natp->nat_level[NAT_RLEV], §);
|
||||
|
||||
work = new_work(§,
|
||||
total_work(sect.sct_work, etu_per_update,
|
||||
civs, sect.sct_item[I_MILIT], uws,
|
||||
maxworkers));
|
||||
bwork = work / 2;
|
||||
|
||||
if (sect.sct_off)
|
||||
continue;
|
||||
|
||||
natp = getnatp(sect.sct_own);
|
||||
work = do_feed(§, natp, etu_per_update, 1);
|
||||
bwork = work / 2;
|
||||
|
||||
type = sect.sct_type;
|
||||
eff = sect.sct_effic;
|
||||
if (sect.sct_newtype != type) {
|
||||
|
@ -164,14 +154,13 @@ prod(void)
|
|||
continue;
|
||||
|
||||
if (type == SCT_ENLIST) {
|
||||
int maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
||||
int maxmil;
|
||||
int enlisted;
|
||||
|
||||
if (sect.sct_own != sect.sct_oldown)
|
||||
continue;
|
||||
enlisted = 0;
|
||||
maxmil = MIN(civs, maxpop) / 2 - sect.sct_item[I_MILIT];
|
||||
maxmil = sect.sct_item[I_CIVIL] / 2 - sect.sct_item[I_MILIT];
|
||||
if (maxmil > 0) {
|
||||
enlisted = (etu_per_update
|
||||
* (10 + sect.sct_item[I_MILIT])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue