minor races placed on left bug question

General Modding Information/Questions; support/discussion/questions

Moderator: thunderchero

Forum rules
:idea: Please search before starting new topic. :idea:
There is a good chance it has already been asked.
Post Reply
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

minor races placed on left bug question

Post by thunderchero »

Hi Everyone,

calculation, have always been my main weakness. So I thought I would ask for some suggestions.

On larger maps there has always been an issue of minors generating mainly on the left of map. we know this is due to the shared "minor density" value

position: 0x17D668
length: 8 bytes
default value: 0.2

this value looks to be calculated, but I don't understand how or what the results would be. could some one explain please?

Code: Select all

AUTO:004B1C4A DC 1D 68 F8 57 00                               fcomp   ds:minor_density_0_2
AUTO:004B1C50 DF E0                                           fnstsw  ax
AUTO:004B1C52 9E                                              sahf
while looking at code in de-bugger I noticed this code loops on every minor placement?

I also noticed every time it loops though this code we have a registry esp+52 for long edge of map and or esp+56 for short edge of map.

Could we use this to get a better placement of minors?

If so could someone give me a code suggestion? I would be happy to test and fine tune.

thunderchero
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3197
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: minor races placed on left bug question

Post by Flocke »

I'm not into asm analysis atm, but my guess would be that it loops through all the systems to place minors and in there it loops through all the systems already processed to check whether it is too close by the minor density modifier to locate another minor at the current system.
When like you posted the minor density default is a relative value, for distance comparison it needs to calculate absolute distance allowed somehow. This is likely done by taking the edge length into account.

All by guess from what you posted. ;)
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Re: minor races placed on left bug question

Post by Spocks-cuddly-tribble »

thunderchero wrote: Fri Apr 16, 2021 8:52 pmCould we use this to get a better placement of minors?
The placement of the minor races is not fully analysed yet.

It's a multifactorial issue, which at some point even caused a small dispute between Dcer and Gowron; cf. minor race frequency (the unknown values are used and even more variables, we just don't understand how).

ASM analysis and logic -wise it's a interesting riddle. And IIRC at your request, I tried for about 90 minutes to analyse the code before I gave up, due to my insuficient knownedge of the BotF map data handling and the very intricate esp storage of the involved variables.

IIRC I suggested a dynamic adjustment workaround, using the number of starsystems on the map, which I presume didn't work.

Since I'm not even able to finish my own projects (like AI TC command probabilities), it's unrealistic that I can assist you here.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: minor races placed on left bug question

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sat Apr 17, 2021 3:36 pm IIRC I suggested a dynamic adjustment workaround, using the number of starsystems on the map, which I presume didn't work.
one option I was considering would be to "cmp" for long edge of large map to a different minor race frequency value, but this would not be a universal patch and only work if galaxy has same large long edge or would require edit.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: minor races placed on left bug question

Post by thunderchero »

Hi Everyone,

Here is a patch that will address the issue of minor mainly on left of map on larger maps.

Prerequisites
relocation patch.
The patch needs to be adjusted for large and medium map long (horizontal) edge.
The patch also will need adjustment of the large/medium minor density values.

note; small maps use the vanilla minor density value and location.

here is the code changes (note; changes are the same but patch location have changed)

Code: Select all

4B1C4A 90                                            nop
4B1C4B E8 50 8F 1D 00                                call    sub_68ABA0

68ABA0 83 7C 24 38 19                                cmp     [esp+arg_34], 19h
68ABA5 73 0E                                         jnb     short loc_68ABB5
68ABA7 83 7C 24 38 10                                cmp     [esp+arg_34], 10h
68ABAC 73 0E                                         jnb     short loc_68ABBC
68ABAE DC 1D 68 F8 57 00                             fcomp   ds:dbl_57F868
68ABB4 C3                                            retn
68ABB5 DC 1D D8 AB 68 00                             fcomp   ds:dbl_68ABD8
68ABBB C3                                            retn
68ABBC DC 1D D0 AB 68 00                             fcomp   ds:dbl_68ABD0
68ABC2 C3                                            retn

68ABD0 33 33 33 33 33 33 D3 3F       dbl_68ABD0      dq 3.0e-1
68ABD8 9A 99 99 99 99 99 D9 3F       dbl_68ABD8      dq 4.0e-1
since changes are required here is text version of patch

Code: Select all

NAME: Minors on left (fix) 
AUTHOR: thunderchero
DESC: This patch allows 3 seperate minor density values (large, Med, small)
DESC: Note this patch requires relocation.patch
DESC: Note this patch also requires editing to match map value and adjustment.
DESC: patch file name: minor_left.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=53964#p53964
TAG: 

# >>  = current value

# <<  = new value

>> 0x000b104a dc 1d 68 f8 57
>> 0x0019f7e0 00 00 00 00 00 00 00 00 
>> 0x0019f7e8 00 00 00 00 00 00 00 00
>> 0x001a17d0 00 00 00 00 
>> 0x001a17d4 00 
>> 0x001a17d5 00 00 00 00 00 00 
>> 0x001a17db 00 
>> 0x001a17dc 00 00 00 00 00 00 00
>> 0x001a17e4 00 00 00 00 00 00
>> 0x001a17eb 00 00 00 00 00 00
>> 0x001a17f2 00

<< 0x000b104a 90 e8 80 a7 1d
#new medium minor density values
<< 0x0019f7e0 33 33 33 33 33 33 d3 3f 
#new large minor density values
<< 0x0019f7e8 9a 99 99 99 99 99 d9 3f
<< 0x001a17d0 83 7c 24 38 
#large map long (horizontal) edge
<< 0x001a17d4 19 
<< 0x001a17d5 73 0e 83 7c 24 38 
#medium map long (horizontal) edge
<< 0x001a17db 10 
<< 0x001a17dc 73 0e dc 1d 68 f8 57
<< 0x001a17e4 c3 dc 1d e8 a3 68
<< 0x001a17eb c3 dc 1d e0 a3 68
<< 0x001a17f2 c3
hope this helps
thunderchero
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Re: minor races placed on left bug question

Post by Spocks-cuddly-tribble »

That doesn't seem right. Your code uses higher density values for larger maps (jnb equivalent jge)?

And if you don't use the long edge for calculations, you can use the galaxy size ds:5A36B8(0-2) as dynamic switch.

cmp byte [5A36B8], 1
jg -> large
je -> medium
else (or jl) -> small


Coming back to your initial question, the "minor density" is compared to a random value from 0 to 1 (i.e. default 0.2 = 20%).

Gowron said it seems to be the base chance (amongst many other factors) that a given star system can get a minor race (map scanned from left to right). Note the first four minors ignore minor density and are set by chaos random.

So if you want 30 minors on "many" for all map sizes (and avoid the left accumulation), it should be lower for larger maps (with more stars), not higher?


But there is still a lot of research to do in this area.

sub_4B22A0 max minors by galaxy size and minor races setting (table value -1) behavior change if 4- minors (i.e. not -1)

sub_4B2350 min minors by galaxy size and minor races setting (+/-?) ignored if 1000 times not reachable due to number of star system vs density vs max setting

Unknown: 004B2201 mov word ptr [ebx], 2 // for 'small spiral' all other 1


Gowron said: 'Minor Races "go extra", so maps with many minors will generally have more star systems than maps with few or no minors.'

There is no code indication for this, unless is has something to do with galaxy shape and density?
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: minor races placed on left bug question

Post by thunderchero »

Just to be clear no mod needs this except galaxy mod. since galaxy mod has such difference between small (27 long edge) and large (65 long edge) map

in that sub the current long edge is always loaded at [esp+arg_34]
thunderchero wrote: Tue Apr 20, 2021 11:38 am The patch needs to be adjusted for large and medium map long (horizontal) edge.
The patch also will need adjustment of the large/medium minor density values.
the current values in patch have not been tested since it was stated they need to be adjusted depending on map sizes used.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: minor races placed on left bug question

Post by Tethys »

Very nice, I will get to testing this soon, now that I have full control over spiral generation :cool:
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
Post Reply

Return to “General Modding Information/Questions”