]> git.pond.sub.org Git - empserver/commit
update: Reorder unit building and maintenance for fairness
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 10 Jul 2016 21:08:57 +0000 (23:08 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:08:31 +0000 (20:08 +0200)
commitc5df505c9885a26f9eac831d8954ce7ec4e6556b
treeada29c332d73361046ac1fa395d4cccb700da221
parent70f69640e110f325b0c2b186ec10866a21ca6c9e
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>
include/update.h
info/Update-sequence.t
src/lib/commands/budg.c
src/lib/update/land.c
src/lib/update/main.c
src/lib/update/plane.c
src/lib/update/ship.c
tests/update/99-POGO
tests/update/final.xdump
tests/update/journal.log
tests/update/setup-POGO