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

@ -26,12 +26,12 @@ This document gives a rough order of events during the update.
e) pay for military reserves.
2) Produce
a) ship maintenance, in order of country number
a) ship maintenance, in order of ship number
pay maintenance, then feed and plague people on board
b) plane maintenance, in order of country number
c) land unit maintenance, in order of country number
b) plane maintenance, in order of plane number
c) land unit maintenance, in order of land unit number
pay maintenance, then feed and plague people on board
g) sectors, in order of country number
d) sectors, in order of country number
a) people in non-sanctuary sectors eat
If not enough is available, the excess people will
starve off. No more than 50% of the people
@ -45,12 +45,12 @@ This document gives a rough order of events during the update.
e) sectors that are stopped are skipped (see info stop)
f) first increase eff
g) then make things
d) ship building, in order of country number
d) ship building, in order of ship number
first increase efficiency, then produce
stopped ships are started, but not built (see info stop)
e) plane building, in order of country number
e) plane building, in order of plane number
stopped planes are started, but not built (see info stop)
f) land unit building, in order of country number
f) land unit building, in order of land unit number
stopped land units are started, but not built (see info stop)
3) Then, do deliveries for all sectors in the world, row by row, going from