But all values suffer from a VERY hard coded two byte limit with a predisposition for overflow bugs, except the hall of fame max score:
Turner wrote:Botf seems to have a problem with the correct calculation of the score from an empire, if the cumulative value of these empire exceeds a specific threshold. If this happens, the calculation of the score begins again with zero.
This does affect:
- score percentages (intel screen - empire status)
- power graph (end game screen)
- total score after winning the match
- some espionage reports
- AI behavior
Military Score (sub_44EE20)
Military Score = [build cost of all: ships except colony ships + (stations / systems held) + (orbital batteries and shield generators / 2)] / 20
An excellent analysis, pretty accurate, except for the cumulated build cost of the stations, which gets divided by systems held; and OB & SH costs are divided by 2:Turner wrote:Value of the ships (without colony ships) + (Value of all stations * 0,3) + Value of all orbital batteries and shield generators
Code: Select all
-> stations
0044EF65 div ecx // divide cumulated build cost of the stations by systems held
-> ships
loc_44F0A4 // add build cost if ship function is 0-4 or 9 = no colony ships
-> buildings
0044EFF6 cmp dl, 13h // check building output ID -> SH
0044F0F3 cmp dl, 11h // check building output ID -> OB
0044F011 shr eax, 1 // divide building costs by 2
Again pretty accurate, it's exactly 1310700 = 65535 (2 byte word/unsigned) * 20Turner wrote:I've boosted the price for a sovereign up to 65535 and so I've needed only 21 of them to exceed the threshold... close by 1310500
Code: Select all
0044F035 mov ecx, 14h // divide end result by 20
Just the cumulated build cost of war fleets (ship functions 0-4) i.e. the effective offensive firepower or military dangerousness of empires would be even better to help the AI to determine times for aggressive and/or demanding behavior (provided there is an actual ratio of build costs & fighting capacities of war ships).
Economic Score (sub_44EC20)
Economic Score = [(total credits / 10) + (income * 10) + current food, industry, energy, research & intel output of all systems held] / 4
Code: Select all
0044EC62 mov ecx, 0Ah // divisor for total credits from [empsInfo+98h]
0044EC73 lea eax, [edx*4] // 4* income from [empsInfo+9C]
0044EC7A add eax, edx // 4* income + income = 5* income
0044EC7C add eax, eax // double (5* income) = 10* income
-systems held / read systInfo loop-
0044EC9E add ecx, [eax+2ACh] // Food output total after bonuses
0044ECA6 mov esi, [eax+2C4h] // Industry output total after bonuses
0044ECAC mov bx, [eax+2B6h] // Energy output total after bonuses
0044ECB3 mov ebp, [eax+2C8h] // Research output total after bonuses
0044ECBB mov ebx, [eax+2D8h] // Intel output total after bonuses
0044ECD9 shr ecx, 2 // end divisor 2^2 = 4
Needless to say that we, as well as the AI, really don't care about the totally unrelated food, energy, research and intel outputs.
An example for an alternative approach:
Economic Score = [(total credits / 32) + income + (current + nominal -industry output of all systems held / 8 )] / 8
Code: Select all
trek.exe at 0x4E06A new code 0x72 bytes:
E8 05 90 90 89 C1 8B 53 04 90 90 90 90 90 90 90 90 90 90 90 03 CA 8B 46 50 E8 78 CE 0C 00 89 C2 85 C0 74 46 0F BF 02 69 D8 28 03 00 00 A1 C8 36 5A 00 01 D8 8B 98 C4 02 00 00 03 98 90 01 00 00 C1 EB 03 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 89 D0 01 F1 E8 D6 CA 0C 00 90 90 89 C2 01 D9 85 C0 75 BA 31 C0 8A 04 24 C1 E9 03
asm code changes:
0044EC69 C1E8 05 SHR EAX, 5 // total credits /2^5 = /32
0044EC6C 9090 NOP
0044EC73-44EC7D 90 NOP
0044EC7E 03CA ADD ECX, EDX // income
0044EC9E 8B98 C4020000 MOV EBX, [EAX+2C4] // current industry output
0044ECA4 0398 90010000 ADD EBX, [EAX+190] // add nominal industry output
0044ECAA C1EB 03 SHR EBX, 3 // divide by 2^3 = 8
0044ECAD-44ECC0 90 NOP
0044ECCA 9090 NOP
0044ECD9 C1E9 03 SHR ECX, 3 // divide end result by 2^3 = 8
+ income / 8
+ total credits / 256
+ for all systems held [arithmetic average of current & nominal industry output] / 32
Income / Industry ratio = 4:1 (for ship scrap resp. trade goods 1:1 mods, this can be up to 1:1, of course)
Empire Status - Intel Screen - issues:
- the vanilla economic & military percentages (based on the results of sub 44EC20 & 44EE20) seem to be bugged
- also when meeting an other empire before turn 3 the empire status shows just question marks instead of the percentages
Code: Select all
sub_4BF0A0 -> sub_4BE528
004BE714 mov edx, 64h // percentage factor loaded as divisor into FPU