Planet Growth Values ; habit.bin

Planet GrowthValues ; habit.bin; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Planet Growth Values ; habit.bin

Post by Gowron » Thu May 01, 2008 4:15 pm

This posting used to be part of a relatively long thread about population growth, but it containes the complete information about how planets affect growth :)

Be warned, this topic is kinda technical ;)


-------------------------------------------------------------------------
-------------------------------------------------------------------------


Good news, I've found the constants that are controlling the growth rates in trek.exe and can now give a more precise algorithm for the growth rate calculation.
The not-so-good news is that it's a bit more complicated since there are several constants involved, and not everything is linear.

I'll call the constants p, q, r, s, t, u, v, w.
p is not used in the calculations, but that seems to be a bug (see below).

All of the following values are stored in trek.exe.

p
start position: 0x0017db84
size: 8 bytes (double)
default value: 0.1
meaning: unknown/unused (probably meant to be the barrier multiplier for small planets)
I tried changing this value from 0.1 to 2000.0, but it didn't seem to have any effect.

q
start position: 0x0017db8c
size: 8 bytes (double)
default value: 0.1
meaning: quadratic multiplier for growth rates, barrier value for small planets
warning: increasing this value will lower the max. accuracy of growth rates (see below)

r
start position: 0x0017db94
size: 8 bytes (double)
default value: 0.001
meaning: linear multiplier for growth rates

s
start position: 0x0017db9c
size: 8 bytes (double)
default value: 1.5
meaning: growth rate multiplier for large planets

t
start position: 0x0017dba4
size: 8 bytes (double)
default value: 0.4
meaning: barrier value for large planets

u
start position: 0x0017dbac
size: 8 bytes (double)
default value: 0.2
meaning: barrier value for medium planets

v
start position: 0x0017dbb4
size: 8 bytes (double)
default value: 0.5
meaning: growth rate multiplier for small planets

w
start position: 0x0017dbbc
size: 4 bytes (float)
default value: 10.0
meaning: global multiplier







Growth Rate Calculation Step by Step

1. Determine planet class and atmosphere type and get the corresponding habitability value from habit.bin.
If the habitability value is undefined, then the planet 's growth rate is now set to the substitute value (see below) according to the planet's size, and then proceed to step 6. Else, proceed to step 2.

2. If the planet is part of a minor race starting system, multiply the habitability value by the minor race growth value from race.rst. Cut the result at the decimal point. If the cut result is zero, then the planet 's growth rate is now set to 0.0 (and in that case all further calculations are skipped). If that's not the case or if the planet is not part of a minor race starting system, proceed to step 3.

3. If the planet is large, multiply the result from step 2 by s. If the planet is small, multiply by v instead. Proceed to step 4.

4. Determine the planet's growth rate via the following formula:
[growth rate] = [max. population] * r * q * [result from step 3] * 10.0%
Proceed to step 5.

5. If the result from step 4 is lower than the barrier value (see below), it is replaced by the substitute value (see below). In any case, proceed to step 6.

6. Multiply by w.
Cut the result at the decimal point.
Then multiply by q.
(thus, all possible growth rates are multiples of q; this is how q affects the max. accuracy)


It is possible that the barrier value for small planets was originally meant to be p, and it was accidentally replaced by q. Since the default values for p and q are the same, maybe no one noticed the bug since it does not have any effect in the default setup.


Substitute Values

The substitute value also depends on the planet's size.

For small planets, it's
0.1

For medium planets, it's
0.2

For large planets, it's
0.4
Last edited by Gowron on Sat Sep 27, 2008 4:58 pm, edited 2 times in total.

User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Habitability Values

Post by Gowron » Thu May 01, 2008 5:13 pm

habit.bin
14 groups, each group consists of 8 bytes

1st byte: planet class
2nd byte: atmosphere type
3rd byte: habitability value for Cardassians
4th byte: habitability value for Humans
5th byte: habitability value for Ferengi
6th byte: habitability value for Klingons
7th byte: habitability value for Romulans
8th byte: habitability value for minors or unoccupied systems

The 4th and 8th values are always the same by default.

User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Post by Gowron » Sat Sep 27, 2008 4:54 pm

Update:

After looking through the assembler code, the algorithm (which had been the result of testing , not code analysis) seems to be exactly what the game is doing, with the multiplications in step 3 and 4 not necessarily being performed in that order.


The check within step 2 (which can lead to all further calculations being skipped) is located in trek.exe at position 0xB7476.
Assembler code:

Code: Select all

85FF           // test edi, edi
0F843C010000   // je 004B81BA
To disable the test, just overwrite those 8 bytes with "90"s :)



The substitute values are each composed of two parts, which are read separately, stored in a row and then loaded into the FPU as a whole.

Substitute Value for small planets (position 0xB75D4):

Code: Select all

BE9A999999    // mov esi, 9999999A
BF9999B93F    // mov edi, 3FB99999
Substitute Value for medium planets (position 0xB763B):

Code: Select all

B99A999999    // mov ecx, 9999999A
BB9999C93F    // mov ebx, 3FC99999
Substitute Value for large planets (position 0xB767E):

Code: Select all

B89A999999    // mov eax, 9999999A
BA9999D93F    // mov edx, 3FD99999
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.

Post Reply

Return to “Planet GrowthValues ; habit.bin”

Who is online

Users browsing this forum: No registered users