update: Reorder unit building and maintenance for fairness

The update visits ships, planes and land units in increasing order of
country number.  Within a country, it visits first ships, then planes,
then land units, each in increasing order of unit number.

The order is relevant when money, materials and work don't suffice to
build everything.

Money is charged to the owner, so only the relative order for the same
owner matters there.  One order is as good as any.

Work and materials come from the sector, so only the relative order in
each sector matters.  The current order unfairly prefers countries
with lower country numbers.  Mitigating factor: the affected countries
need to be friendly (ships only) or allied.

The unfairness goes back to Chainsaw's option BUDGET.  See the commit
before previous for more detailed historical notes.

The update test demonstrates the unfair behavior: sector 14,6 builds
ships 95/97 owned by country#1, but not 96 owned by country#7.
Likewise, planes 95/96/97 and land units 95/96/97.

Go back to the the pre-BUDGET order: first ships, then planes, then
land units, all in increasing order of unit number, regardless of
owner.

The update test now builds ship, plane and land unit 96 instead of 97.

Bonus: speeds up both the update and budget by a similar absolute
amount.  For budget, this is roughly a factor of two in my testing.
For the update, which does much more, it's around 10%.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-07-10 23:08:57 +02:00
parent 70f69640e1
commit c5df505c98
11 changed files with 152 additions and 173 deletions

View file

@ -98,8 +98,8 @@ extern int feed_people(short *, int);
extern double food_needed(short *, int);
extern int famine_victims(short *, int);
/* land.c */
extern void prep_lands(int, natid);
extern void prod_land(int, int, struct bp *, int);
extern void prep_lands(int);
extern void prod_land(int, struct bp *, int);
/* main.c */
/* in server.h */
/* material.c */
@ -122,8 +122,8 @@ extern void do_plague(struct sctstr *, int);
extern int plague_people(struct natstr *, short *, int *, int *, int);
extern void plague_report(natid, int, int, int, int, char *, char *);
/* plane.c */
extern void prep_planes(int, natid);
extern void prod_plane(int, int, struct bp *, int);
extern void prep_planes(int);
extern void prod_plane(int, struct bp *, int);
/* populace.c */
extern void populace(struct sctstr *, int);
extern int total_work(int, int, int, int, int, int);
@ -148,7 +148,7 @@ extern void spread_fallout(struct sctstr *, int);
extern void decay_fallout(struct sctstr *, int);
extern void produce_sect(struct natstr *, int, struct bp *);
/* ship.c */
extern void prep_ships(int, natid);
extern void prod_ship(int, int, struct bp *, int);
extern void prep_ships(int);
extern void prod_ship(int, struct bp *, int);
#endif