the AI minimum terraform threshold

the AI minimum terraform threshold; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 848
Joined: Sun Apr 27, 2008 2:00 am

the AI minimum terraform threshold

Post by Spocks-cuddly-tribble » Wed Nov 04, 2009 5:04 pm

If the AI decides colonisation of a specific system, sub_41BF00 tests (among others) the need of further terraforming:

Code: Select all

41C015   cmp   eax, 4Bh    //  test current MAX POP
41C018   jnb   short loc_41BFD4
This means a system must reach at least a MAX POP of 75. Otherwise AI is forced to terraform more planets.


Limitations which can override the threshold: :?
  • total system capacity is less than the limiting value
  • at the time an AI colony ship arrives a system there is a MAX POP larger 0
    (M-class planets or previous terraforming)
[EDIT] solved (see below):
410134 jnz short loc_410143 // 0xF534 -> 75 0D to 90 90
[EDIT/]


Since this check, due to its structure, can only work for a maximum value of 127(dec), we could remove the following jump statement:

At 0x1B418 -> 73 BA to 90 90

(Same effect: 41BF87 jz short loc_41BFCE // 0x1B387 -> 74 45 to 90 90)

Either of them forces the AI to fully terraform the system before colonizing it.
Last edited by Spocks-cuddly-tribble on Mon Feb 08, 2010 9:45 am, edited 1 time in total.
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: 6452
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: the AI minimum terraform threshold

Post by thunderchero » Wed Nov 04, 2009 10:06 pm

Thanks Spocks-cuddly-tribble,

This will be added to UDM, This should increase AI strengh with more money and ground combat too. :D I also noticed now AI went back and completely terraformmed a minor system after subjugating :wink:

Edit: I have been testing The minor had all class M, Do you think it can be adapted to terraform all classes of planets?

thunderchero

User avatar
Martok
Rear-Admiral
Rear-Admiral
Posts: 1156
Joined: Thu May 01, 2008 2:00 am

Post by Martok » Wed Nov 04, 2009 11:30 pm

Outstanding! Hopefully this will be worked into BOP as well.
"Evil is easy, and has infinite forms." -- Pascal

stardust
Rear-Admiral
Rear-Admiral
Posts: 1381
Joined: Sat Apr 26, 2008 2:00 am
Location: good ole Blighty

Post by stardust » Thu Nov 05, 2009 1:40 am

I've a question/spanner in the works here.

If this code is meant to force the AI to terraform a system to 75 pop before colonising, then how come I've seen the AI pick a perfectly good system to colonise but only terraform a naff J or Y class planet that only has 15/20 pop and colobnise then?

It's not like this has been a one off in my experience. I've seen it happen dozens of times over the years on Vanilla.
Computers! [Expletive deleted]

My 4shared folder

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 6452
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Post by thunderchero » Thu Nov 05, 2009 1:54 am

I am not an expert on this, but it may have been due to no class M planets in that system? so this part of code was over looked.

thunderchero

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 848
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble » Thu Nov 05, 2009 1:18 pm

thunderchero wrote:This should increase AI strengh with more money and ground combat too.
Be careful, it slows down AI expansion (especially low tech/epic games). So maybe a 50% increase of colony ships in the AI fleet buildup agendas could be recommended. Note due to longer terraform times AI builds lesser of them!
thunderchero wrote:I also noticed now AI went back and completely terraformmed a minor system after subjugating
Must be coincidence. AI terraform behavior after colonizations/subjugations seems unaffected by sub_41BF00.
thunderchero wrote:The minor had all class M, Do you think it can be adapted to terraform all classes of planets?
1.) This probably is a MAX POP larger 0 issue, not a class M specific problem
2.) As I said, sub_41BF00 only applies to unhabitated systems! (Do you intend to bomb all minors to death?)

Concerning an adaption of the MAX POP > 0 issue. Just tell me the code location and I'd be happy to adapt it for you. :wink:
stardust wrote:how come I've seen the AI pick a perfectly good system to colonise but only terraform a naff J or Y class planet that only has 15/20 pop and colobnise then?
I'm not sure. Note this is a small part of a large jigsaw only.

Possible:
1.) Terraform task was interrupted i.e.an AI colony ship (re-)arrives a system with a current MAX POP larger 0 -> limit overriden
2.) It also might be that some sort of AI-diplomacy agenda can override sub_41BF00

Also, durring my tests, AI always selected the pop(or growth?) largest planet for next the terraforming task. But at the same time, I think I share your memories.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

stardust
Rear-Admiral
Rear-Admiral
Posts: 1381
Joined: Sat Apr 26, 2008 2:00 am
Location: good ole Blighty

Post by stardust » Sat Nov 07, 2009 10:16 am

Spocks-cuddly-tribble wrote:
stardust wrote:how come I've seen the AI pick a perfectly good system to colonise but only terraform a naff J or Y class planet that only has 15/20 pop and colobnise then?
I'm not sure. Note this is a small part of a large jigsaw only.

Possible:
1.) Terraform task was interrupted i.e.an AI colony ship (re-)arrives a system with a current MAX POP larger 0 -> limit overriden
2.) It also might be that some sort of AI-diplomacy agenda can override sub_41BF00

Also, durring my tests, AI always selected the pop(or growth?) largest planet for next the terraforming task. But at the same time, I think I share your memories.
Combat does seem to have some overriding effect on this code change.

I'm running a game on AAM at the moment with the MUDD cheats on to see how the AI is handling things and I've noticed the Federation have colonised a system that had an L type planet previously terraformed.

The colony ship started terraforming this system but something's caused the colony ship to retreat (I didn't see who engaged them though.)

The following turn the colony ship was back and colonised the system without bothering to finish terraforming any other planets.
Computers! [Expletive deleted]

My 4shared folder

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 848
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble » Sat Nov 07, 2009 11:02 am

stardust wrote:The colony ship started terraforming this system but something's caused the colony ship to retreat (I didn't see who engaged them though.)
That's a mod-independent AI behavior(temporary conflicting orders) and has nothing to do with combat.
stardust wrote:The following turn the colony ship was back and colonised the system without bothering to finish terraforming any other planets.
That's my point 1.) above - no matter which cause.


A funny/odd thing I forgot to mention: previous terraforming by a human/player doesn't override the limit.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 848
Joined: Sun Apr 27, 2008 2:00 am

Re: the AI minimum terraform threshold

Post by Spocks-cuddly-tribble » Sun Nov 08, 2009 1:09 pm

thunderchero wrote:Do you think it can be adapted to terraform all classes of planets?
This should work for you, and also reduce (a bit) the conflicting orders issue:


410134 jnz short loc_410143 // 0xF534 -> 75 0D to 90 90

The problem is/was: AI selects orders (colonize/terraform) already at the time of beginning of the colony ships movement. :?


For the other big problem (prolonged terraforming tasks), we'd need an AI terraform cheat (maybe each planet = 1 turn).
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: 6452
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: the AI minimum terraform threshold

Post by thunderchero » Wed Jun 03, 2020 10:35 am

Hi everyone,

I might have found a fix for AI to terraform all system before colonizing.

I have been testing on MUM, vanilla and ECM

so far on my test it works great. Only issue I have seen sometimes they stop terraforming for a different task, but I expect that task has higher priority?

code changes

Code: Select all

00410134 90 90                                           nop //skip terraform if M-Class present

0041BFB6 0F 85 77 00 00 00                               jnz     loc_41C033 // change/correct offset

0041BFE0 7D 51                                           jge     short loc_41C033 // change/correct offset

0041C002 74 1D                                           jz      short loc_41C021 // change/correct offset

move below 2 bytes forward
0041C015 3D E8 03 00 00                                  cmp     eax, 3E8h //  test current MAX POP (1000) 
0041C01A 73 B8                                           jnb     short loc_41BFD4 // change/correct offset

0041C01C E9 68 FF FF FF                                  jmp     loc_41BF89 // change/correct offset

0041C021 80 7E 48 03                                     cmp     byte ptr [esi+48h], 3
0041C025 74 DD                                           jz      short loc_41C004 // change/correct offset

0041C027 B8 01 00 00 00                                  mov     eax, 1
0041C02C 5D                                              pop     ebp
0041C02D 5F                                              pop     edi
0041C02E 5E                                              pop     esi
0041C02F 5A                                              pop     edx
0041C030 59                                              pop     ecx
0041C031 5B                                              pop     ebx
0041C032 C3                                              retn

0041C033 31 C0                                           xor     eax, eax
0041C035 5D                                              pop     ebp
0041C036 5F                                              pop     edi
0041C037 5E                                              pop     esi
0041C038 5A                                              pop     edx
0041C039 59                                              pop     ecx
0041C03A 5B                                              pop     ebx
0041C03B C3                                              retn
patch

Code: Select all

NAME: Force AI to terraform all planets before colonizing
AUTHOR: thunderchero
DESC: This patch Force AI to terraform all planets before colonizing
DESC: patch file name: Force_AI_to_terraform.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?f=199&t=491&p=33996#p339963996
TAG: mirror universe patch
 
# >>  = vanilla/original value

# <<  = new value


>> 0x0000f534 75 0d
>> 0x0001b3b8 75
>> 0x0001b3e1 4f
>> 0x0001b403 1b
>> 0x0001b415 83 f8 4b 73 ba e9 6a ff ff
>> 0x0001b41f 80 7e 48 03 74 df b8 01 00 00
>> 0x0001b42a 5d 5f 5e 5a 59 5b c3 31 c0 5d 5f 5e 5a 59 5b c3 00 00

<< 0x0000f534 90 90
<< 0x0001b3b8 77
<< 0x0001b3e1 51
<< 0x0001b403 1d
<< 0x0001b415 3d e8 03 00 00 73 b8 e9 68
<< 0x0001b41f ff ff 80 7e 48 03 74 dd b8 01
<< 0x0001b42a 00 00 5d 5f 5e 5a 59 5b c3 31 c0 5d 5f 5e 5a 59 5b c3

Post Reply

Return to “the AI minimum terraform threshold”

Who is online

Users browsing this forum: No registered users