empserver/tests/update/99-POGO
Markus Armbruster 75c8d9c72f update/revolt: Fix how land units take casualties
take_casualties() applies a number of casualties to sector military
and land units.  It is utterly confused about land units.

Consider a land unit with efficiency eff that has mil out of maxmil
military.  Issues:

* To apply N casualties without destroying it, take_casualties() tries
  to kill N * maxmil / mil military.  Makes no sense.  It's more than
  asked for unless mil equals maxmil.  It can even be more than mil.

  It reduces efficiency by N * 100 / mil points.  Note that ordinary
  ground combat reduces by N * 100 / maxmil points.  See
  lnd_take_casualty().

  Example: the update test's inf#25 is 100% efficient and has 20m out
  of 100m.  take_casualties() tries to apply up to 22 casualties out
  of the 60 remaining casualties to apply, but decides to apply only
  12 for now, to keep efficiency above to 40%.  It reduces efficiency
  by 12 * 100 / 20 = 60 to 40%, and tries to kill 12 * 100 / 20 = 60
  mil, which kills off the 20 that actually exist.  It nevertheless
  reduces the number of casualties still to apply only by 12.

  Example: the update test's linf#28 is 100% efficient and has 20m out
  of 25m.  take_casualties() tries to apply up to 8 casualties.  It
  reduces efficiency by 8 * 100 / 20 = 40 points to 60%, and tries to
  kill 8 * 25 / 20 = 10 military.

* When it destroys a land unit, it reduces the number of casualties
  still to apply by mil * eff/100.0 instead of mil.

  Example: the update test's inf#27 is 10% efficient and has 20m out
  of 100m.  take_casualties() still has 34 casualties to apply, so it
  destroys it, killing all 20m.  But it reduces the number of
  casualties to apply only by 2.

Broken when 4.0.0 made land unit military loadable.  Not sure it fully
worked before that, but it's definitely bonkers since.

Fix it as follows:

* To apply casualties to a land unit without destroying it, limit its
  losses to its actual number of military, and so that efficiency
  stays above 40%.  Then simply kill that number.

* Reduce the number of casualties to apply by the exact number killed.

The update test now kills only 8m in linf#28.  Still two more than it
should, but that's separate bug, to be fixed next.  The fix has no
visible effect for inf#25, because that one gets destroyed later.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 20:09:19 +02:00

238 lines
5.9 KiB
Text

force
show updates
power
read 0
|| country#1
| pop growth
| 2,0 1f for 83+83 babies make 83c 83u
| 4,0 2f for 166+166 babies make 166c 105u
| 6,0 3f for 250+250 babies make 210c 105u
| 8,0 plenty of food make -1000c 100u pop limit
| starvation
| 1,1 33u
| 3,1 100u 33c
| 5,1 100u 50c
| 7,1 100u 20c 30m
| 9,1 16c
| 11,1 6c
| 15,1 16m
| ship#42 25m
| 43 30u 3c
| land#42 25m
| BUG: che don't age in 1,1
| sector building
| 0,2 0% stopped
| 2,2 100% -> 84%-88% 7.8 work, 4 left
| 4,2 100% -> 0% -> 14% 78 work, 39 left
| 6,2 100% -> 0% -> 100% 273 work, 148 left
| 8,2 1% no materials
| 10,2 1% -> 11% f 10h
| 12,2 1% -> 11% c 10l 20h, 30h left
| ship building
| 60 stopped
| 61 neutral harbor
| 70..73 +0.5% at sea
| 74 +1% at sea
| 75 +1% at sea
| 76 +2% at sea limit 80%
| 90/91 friendly harbor with and without work
| 92/93 +0% friendly city without work
| odd: cities don't repair ships
| 95 +80% own harbor
| 97 +0% own harbor, materials limit
| 103 +13% at sea
| 104 +13% at sea
| 113 +5% at sea
| 114 +5% at sea
| plane building
| 60 stopped
| 61 friendly airfield
| 70 +2% carrier at sea
| 71 +1% carrier at sea up to limit 80%
| 72 +1% carrier in allied airfield up to limit 80%
| 75..78 +7.5% allied carrier in friendly airfield
| BUG: avoids "no airfield" malus, uses airfield materials
| 80 +30% in the field
| 81 +20% in the field (weird limit "at most (100-eff)/3")
| 82 no work
| 90/91 +90% allied airfield with and without work
| 92/93 +30% allied city without work
| 95 +50% own airfield
| 97 +0% own airfield, materials limit
| 100 allied airfield where plague killed off mil
| land unit building
| 60 stopped
| 61 friendly hq
| 80 +30% in the field
| 81 +20% in the field (weird limit "at most (100-eff)/3")
| 82 no work
| 90/91 allied fort/hq with and without work
| 92/93 +30% allied city without work
| 95 +90% own hq
| 97 +0% own hq, materials limit
| 98 +90% own fort
| produce sect
| make units avail
| 1,3 m 0i 0 stopped
| 3,3 m 0i 39 inefficient
| 9,3 e 0m 93.6 mil limit
| 11,3 e 30m 78
| 13,3 e 45m 39.6
| -16,4 m 7i 8
| -14,4 m 78i 0
| -12,4 m 26i 1.3
| -8,4 g 7d 8
| -6,4 g 78d 0
| -4,4 g 500d 700 resource limit
| -2,4 ^ 45d 0
| 0,4 a 57.8f 8
| 2,4 a 643.5f 0
| 4,4 a 999f 478.9 product limit
| 8,4 o 6.4o 8
| 10,4 o 71.5o 0
| -15,5 o 6.0u 8
| -13,5 u 66.9u 0
| -11,5 u 244.3u 915 resource limit
| -7,5 i 23.1s 26 0
| -5,5 i 44,4s 50 240
| -3,5 i 88.9s 100 90
| 1,5 d 3.6g 4 14
| 3,5 d 8.9g 10 230
| 9,5 % 693.3p 78 0
| 11,5 % 888.9p 100 56
| 13,5 % 999p 112.4 277.6 product limit
| -16,6 b 15b 15 3
| -14,6 b 20b 20 290
| -12,6 b 6b 6 1.0
| -8,6 j 71.5l 78 0
| -6,6 j 91.7l 100 290
| -4,6 j 999l 1089.8 110.2 product limit
| 0,6 k 35.8h 39 0
| 2,6 k 45.8h 50 290
| 4,6 k 19h 20.7 36.6 backlog
| -15,7 t 2.4 4 14
| -13,7 t 3.0 5 310
| -7,7 r 2.4 4 14
| -5,7 r 3.6 6 294
| 1,7 l 78 78 0
| 3,7 l 100 100 290
| 9,7 p 78 78 0
| 11,7 p 0 0 78
| produce ship
| 100 +40.5f with 100% eff 10 fert
| 101 +405f with 100% eff 100 fert
| 102 stopped
| 103 +243f with 60% eff
| 104 +81f with 20% eff
| 110 +5.14o 100% eff 10 ocont
| 111 +51.4o with 100% eff 100 ocont
| 112 stopped
| 113 +29.0o-29.3o with 60% eff 94-95 ocont
| 114 +9.2-9.6o with 20% eff 91-93 ocont, 90-93 ocont left
read 1
nation 1
cens 0:15,0:3
comm 0:15,0:3
cens -16:15,4:7
comm -16:15,4:7
ship 0:31,0:15
carg 0:31,0:15
plane 0:31,0:15
land 0:31,0:15
|| country#2
| negative money delta
| starvation 0:15,0
| #30 lost 12% to lack of maintenance
| #31 lost 1%
| sector building
| -16:-12,0 no money
| sector production
| -1,3 no money
| ship building
| 65 no money
| plane building
| 65 no money
| land unit building
| 65 no money
read 2
nation 2
cens -16:-1,0:3
comm -16:-1,0:3
peek -16:-1,0:3
ship -32:-1,0:15
plane -32:-1,0:15
land -32:-1,0:15
|| country#3
| civil unrest in 0:15,-8:-5
| loyalty recovery and conversion 0:15,-3
read 3
nation 3
cens 0:15,-8:-1
comm 0:15,-8:-1
peek 0:15,-8:-1
ship 0:31,-16:-1
plane 0:31,-16:-1
land 0:31,-16:-1
|| country#4
| -16,-8 che take over by subversion, take over empty inf#20
| -14,-8 bank, che win, kill inf#22, take over inf#21/23
| BUG: empty inf#21 dies fighting guerrillas
| -12,-8 sec#25 raids, #27 doesn't, che win, kill sec#25/27/inf#26,
| BUG: spy#24 dies fighting guerrillas
| BUG: "Sector -12,-8 has been retaken!" instead of takeover
| -10,-8 che win, don't take over
| -8,-8 che lose
| BUG: che kill 2m more than they should
| -6,-8 che lose
| BUG: inf#29 shouldn't die
| plague stage 4 (dying) -16:-1,-6 ship#10 land#10
| -16,-6 reverts to deity
| -14,-6 resets work etc.
| -12,-6 mil all die
| -10,-6 resets work etc
| -8,-6 reverts to deity
| plague stage 3..1 -16:-1,-5:-3 ship#11..19 land#10..19
| plague stage 0 (healthy) -16:-9,-2, 50% chance to become exposed
| -5,-1 tech too low
| -3,-1 edu too low
read 4
nation 4
cens -16:-1,-8:-1
comm -16:-1,-8:-1
peek -16:-1,-8:-1
| #10 plague deaths
| #61/62 not repaired
ship -32:-1,-16:-1
| #1 sat moved
plane -32:-1,-16:-1
| #10 plague deaths
land -32:-1,-16:-1
|| country#5
| che retake -16:-14,-8
read 5
nation 5
|| country#6
| plane building
| 62 friendly airfield
| 96 +50% allied airfield
| land unit building
| 62 friendly hq
| 96 +50% allied hq, materials limit
read 6
nation 6
cens 0:15,8
comm 0:15,8
|| country#7
| ship building
| 62 neutral harbor
| 96 +20% friendly harbor, materials limit
read 7
nation 7
cens -16:-1,8
comm -16:-1,8
|| resource depletion
reso * ?min>0
reso * ?gold>0
reso * ?fert>0
reso * ?ocont>0
reso * ?uran>0