Author Topic: AI SE changed in patches?  (Read 3131 times)

0 Members and 1 Guest are viewing this topic.

Offline binTravkin

AI SE changed in patches?
« on: May 17, 2015, 12:33:53 PM »
Hi!

I tried playing around with AI SE priorities as configured in the respective ".txt" files and did a test.
It appears that some of the AI SE priorities from txt files are being overriden by exe?

For example - Gaians not taking Green although it's available and still (by default) their "favourite" SE choice, most factions taking Free Market despite .txt specifying them to go for other priorities than economy.

I'm talking about these parts of code in "[FACTION].txt"
Code: [Select]
  Economics, Green, EFFIC
  Economics, Free Market, POLICE
They used to work:
Group, Preferred choice, Preferred SE category (prioritize this in all groups)
Group, Disabled choice, Un-preferred SE category (de-prioritize SE options with this category and vice versa)


Also - did patches alter Former production somehow?
Just wanted to know if most factions building 3-4 (land) formers over the course of 150+ turns and at least a dozen of bases is new or old problem.

Offline Yitzi

Re: AI SE changed in patches?
« Reply #1 on: May 17, 2015, 03:00:50 PM »
Kyrub's patch is what manipulated AI, especially the SMAC version.

Are you finding that it occurs in the SMAX patch, or only the SMAC patch?

Not having many formers is, I think, an older issue.

Offline binTravkin

Re: AI SE changed in patches?
« Reply #2 on: May 17, 2015, 04:15:35 PM »
This test was with SMACX 3.4 patch (latest) from the downloads section.

Is there any way to check if how these settings work was indeed changed?
Any changelog to search for that?
Because it now seems that at least the "undesirable SE category" (2nd row, last) is being either ignored or works inversely - as 2nd "desired" category after the last entry of first row.

I will think how to test it more thoroughly.

Offline binTravkin

Re: AI SE changed in patches?
« Reply #3 on: May 17, 2015, 05:37:21 PM »
The former thing is really bad. :(
I did another 2 test runs.
In the last one 3(!) of the factions had exactly 1 land former!  :o

It can be somewhat improved by adding "Build" as priority for faction, but then they tend to build WAY too many buildings.

Offline Yitzi

Re: AI SE changed in patches?
« Reply #4 on: May 18, 2015, 12:32:39 AM »
This test was with SMACX 3.4 patch (latest) from the downloads section.

Is there any way to check if how these settings work was indeed changed?
Any changelog to search for that?

You'd have to ask kyrub.

The former thing is really bad. :(
I did another 2 test runs.
In the last one 3(!) of the factions had exactly 1 land former!  :o

It can be somewhat improved by adding "Build" as priority for faction, but then they tend to build WAY too many buildings.

I get the idea that it was as bad, or even worse, without the patch.

If you want, when I take nominations for the next patch, you can nominate "start learning how the AI works"; once I do that, I can start teaching it how to be smarter about things like formers...

Offline Lord Avalon

Re: AI SE changed in patches?
« Reply #5 on: May 18, 2015, 04:41:50 AM »
I thought the idea was to have AIs make good SE choices, rather than favored ones.

kyrub's "Improving AI - What are the Priorities?" thread

His 'poly "SMAC 444 (AI Experiment)" thread
Your agonizer, please.

Offline binTravkin

Re: AI SE changed in patches?
« Reply #6 on: May 18, 2015, 11:22:38 AM »
I've read through the threads where people discuss how they done this and that with the EXE with the EXE, like this one: http://alphacentauri2.info/index.php?topic=14229.0
Also downloaded this: https://github.com/OpenSMACX/OpenSMACX
And this: https://github.com/dominx/opensmac (is this somehow related? does it help anyhow?)

However, with only basic C++ knowledge from university, I'm having a hard time even understanding what level of customization is possible at the moment and how difficult it is let alone the tools and actions that needed to make a simplest change.

I've done some AI modding in LUA and text-based AI files (Paradox Interactive games, Age Of Empires), but this is not helpful here.

However, I see that some people have already made some substantial changes to how AI works.

Is there some short introduction what tools one needs and how to do a (simplest) change in terranx.exe and test it?


Quote
I thought the idea was to have AIs make good SE choices, rather than favored ones.

What we have now:
A) Poor AI logic, but ability to influence it via the textfile (old way)
B) Improved AI logic, but ignores(?) the textfile (new way)

It appears that B is not much better than A unless other significant changes are done.
For example, the "agressive" factions tend to build a lot of units, like WAY too many, often whatever amount they can build before running out of minerals.
But then the new logic tells them to run democracy and/or wealth, which defeats their "conqueror" purpose due to either low SUPPORT or low MORALE or both.
In these few test runs I did, Spartans were running Democracy each time no matter if they were at war or not.
It seemed to me that democracy+freemarket+wealth is a hard-coded choice as most factions chose it.
It makes sense for a human player (though not always), but AI is more complicated due to problems in other parts of it's logic.

Due to way how the "conquer" AI currently works, SUPPORT is the single most important SE attribute for aggressive factions as it is the only way for them to not run out of minerals and stagnate with mass of obsolete units.
In such circumstances Power is almost a no-brainer choice for them as the --INDUSTRY is easily swallowed by bonuses from difficulty (IIRC it's equivalent of ++INDUSTRY at transcend) and building less units of higher quality is currently the way to go for the AI as it is not particularly apt in using other force multipliers.
Also, at certain circumstances (Power+Police/Miriam/SpaceRefinery+bases>4pop) extra SUPPORT adds more to a faction's ability to build than extra INDUSTRY, due to freed-up minerals.

Similarly "build" AI tends to build WAY too many buildings even exceeding it's energy production with maintenance requirements and seemingly making little notice of it.
For it, giving more INDUSTRY is a big no-no as it just means it will out-build itself sooner.

Another, less circumstantial insight is that AI does not benefit from high/prioritized GROWTH quite as much as a human player due to these factors:
1. It does not know how to popboom. When it happens, it's an "unintended consequence".
2. It has growth bonuses from difficulty level (IIRC ++GROWTH), which do not work towards popbooming.
3. It is really inefficient at drone control. It does not even check that base is 1 turn from growth and attempt to convert one citizen to doctor.
4. It is really inefficient at police garrisoning. Some bases have 9 garrisons for no apparent reason, some - 1 or none. No prioritizing of "nonlethal methods/police" special ability or units with police bonuses (ogres, mindworms for cult).

So extra GROWTH given to AI may become a mixed blessing and taken away may change very little if anything.
This significantly changes best SE choices calculation for AI vs Human, e.g. Green choice becomes much better while Planned - much worse until you can check for Children's Creches, extra food and Democracy also being present.

Reading the previously linked thread I got the idea that rewriting parts of AI entirely might not be feasible.
What instead could be done is:
1. Rework priority values of units and buildings.
This may suffice to make AI build more of certain types and less of others.
I think this might actually be in the text files?
Actually alphax.txt has basic unit list whereas one of the parameters is "9=Terraformer", but this is never actually used on terraformer, putting -1 (autocalculate) instead.

2. Switch priorities on/off depending on circumstances.
E.g. many factions start without Centauri ecology, which is crucial (if the former building issue is fixed).
If then "Explore" is added as a priority to them, they will research Centauri Ecology.
However, Explore is also added to governor priorities, which means that they will build a significant amount of "explore" units - colony pods and scouts.
This works until there is space to put down colony pods into, but continues even after there is none left.
So instead the Explore priority should be switched off at this point.
I actually found that there are some mentions of such switches, but not sure if this refers to UI or actual switch for AI:
Code: [Select]
0041FF65   mov eax, dword ptr ds:[edx+824]           EXPLORE
00420067   mov ecx, dword ptr ds:[eax+C08]           Activates the Governor^EXPLORE: Scouts, Colony Pods, Transports
00420092   mov eax, dword ptr ds:[edx+828]           DISCOVER
00420194   mov ecx, dword ptr ds:[eax+C0C]           Activates the Governor^DISCOVER: Projects, Prototypes, Probes, Network Nodes
004201BF   mov eax, dword ptr ds:[edx+A54]           Advanced Governor Settings
004202AD   mov eax, dword ptr ds:[eax+724]           Governor
004203AF   mov ecx, dword ptr ds:[eax+C18]           Turns the Governor on or off
004203DA   mov eax, dword ptr ds:[edx+A54]           Advanced Governor Settings
004204C8   mov eax, dword ptr ds:[eax+82C]           BUILD
004205CA   mov ecx, dword ptr ds:[eax+C10]           Activates the Governor^BUILD: Formers and Facilities
004205F5   mov eax, dword ptr ds:[edx+830]           CONQUER
004206F7   mov ecx, dword ptr ds:[eax+C14]           Activates the Governor^CONQUER: Military Units, Command Centers, etc.


EDIT:
I just tested, the Transcend difficulty bonus for AI is +++INDUSTRY and +++GROWTH (previously I wrote its ++).
AI can also exceed the -50% "row" reduction (+++++INDUSTRY) limit, I've seen it have rows with length of 3.
« Last Edit: May 18, 2015, 01:01:39 PM by binTravkin »

Offline Yitzi

Re: AI SE changed in patches?
« Reply #7 on: May 18, 2015, 03:15:03 PM »
Is there some short introduction what tools one needs and how to do a (simplest) change in terranx.exe and test it?

I don't think so.  I've used ollydbg (as did kyrub and scient before me), but I don't know of any actual guides...

Quote
What we have now:
A) Poor AI logic, but ability to influence it via the textfile (old way)
B) Improved AI logic, but ignores(?) the textfile (new way)

It appears that B is not much better than A unless other significant changes are done.
For example, the "agressive" factions tend to build a lot of units, like WAY too many, often whatever amount they can build before running out of minerals.
But then the new logic tells them to run democracy and/or wealth, which defeats their "conqueror" purpose due to either low SUPPORT or low MORALE or both.
In these few test runs I did, Spartans were running Democracy each time no matter if they were at war or not.
It seemed to me that democracy+freemarket+wealth is a hard-coded choice as most factions chose it.
It makes sense for a human player (though not always), but AI is more complicated due to problems in other parts of it's logic.

Due to way how the "conquer" AI currently works, SUPPORT is the single most important SE attribute for aggressive factions as it is the only way for them to not run out of minerals and stagnate with mass of obsolete units.
In such circumstances Power is almost a no-brainer choice for them as the --INDUSTRY is easily swallowed by bonuses from difficulty (IIRC it's equivalent of ++INDUSTRY at transcend) and building less units of higher quality is currently the way to go for the AI as it is not particularly apt in using other force multipliers.
Also, at certain circumstances (Power+Police/Miriam/SpaceRefinery+bases>4pop) extra SUPPORT adds more to a faction's ability to build than extra INDUSTRY, due to freed-up minerals.

Similarly "build" AI tends to build WAY too many buildings even exceeding it's energy production with maintenance requirements and seemingly making little notice of it.
For it, giving more INDUSTRY is a big no-no as it just means it will out-build itself sooner.

Another, less circumstantial insight is that AI does not benefit from high/prioritized GROWTH quite as much as a human player due to these factors:
1. It does not know how to popboom. When it happens, it's an "unintended consequence".
2. It has growth bonuses from difficulty level (IIRC ++GROWTH), which do not work towards popbooming.
3. It is really inefficient at drone control. It does not even check that base is 1 turn from growth and attempt to convert one citizen to doctor.

I think that the AI actually gets to convert to doctor after the drone riot and have it work retroactively...I'm not certain about that, though.

Quote
Reading the previously linked thread I got the idea that rewriting parts of AI entirely might not be feasible.

It is feasible, once I learn how the AI works...and without that, I can't really do anything.

Quote
What instead could be done is:
1. Rework priority values of units and buildings.
This may suffice to make AI build more of certain types and less of others.
I think this might actually be in the text files?

Only for projects...but adding it for other facilities should be doable once I analyze the AI.

Quote
Actually alphax.txt has basic unit list whereas one of the parameters is "9=Terraformer", but this is never actually used on terraformer, putting -1 (autocalculate) instead.

Yes...but I think you could put 9 on something with a weapon to get an armed terraformer.

Quote
2. Switch priorities on/off depending on circumstances.
E.g. many factions start without Centauri ecology, which is crucial (if the former building issue is fixed).
If then "Explore" is added as a priority to them, they will research Centauri Ecology.
However, Explore is also added to governor priorities, which means that they will build a significant amount of "explore" units - colony pods and scouts.
This works until there is space to put down colony pods into, but continues even after there is none left.
So instead the Explore priority should be switched off at this point.
I actually found that there are some mentions of such switches, but not sure if this refers to UI or actual switch for AI:
Code: [Select]
0041FF65   mov eax, dword ptr ds:[edx+824]           EXPLORE
00420067   mov ecx, dword ptr ds:[eax+C08]           Activates the Governor^EXPLORE: Scouts, Colony Pods, Transports
00420092   mov eax, dword ptr ds:[edx+828]           DISCOVER
00420194   mov ecx, dword ptr ds:[eax+C0C]           Activates the Governor^DISCOVER: Projects, Prototypes, Probes, Network Nodes
004201BF   mov eax, dword ptr ds:[edx+A54]           Advanced Governor Settings
004202AD   mov eax, dword ptr ds:[eax+724]           Governor
004203AF   mov ecx, dword ptr ds:[eax+C18]           Turns the Governor on or off
004203DA   mov eax, dword ptr ds:[edx+A54]           Advanced Governor Settings
004204C8   mov eax, dword ptr ds:[eax+82C]           BUILD
004205CA   mov ecx, dword ptr ds:[eax+C10]           Activates the Governor^BUILD: Formers and Facilities
004205F5   mov eax, dword ptr ds:[edx+830]           CONQUER
004206F7   mov ecx, dword ptr ds:[eax+C14]           Activates the Governor^CONQUER: Military Units, Command Centers, etc.

Yeah, situational priorities would be highly desirable.  (Although I'm wondering if it might be better to have formers buildable from the start and have Centauri Ecology give some important terraforming instead.)

Quote
EDIT:
I just tested, the Transcend difficulty bonus for AI is +++INDUSTRY and +++GROWTH (previously I wrote its ++).
AI can also exceed the -50% "row" reduction (+++++INDUSTRY) limit, I've seen it have rows with length of 3.

Yes...what actually happens, I think, is that it has a decrease to the units per row, and then INDUSTRY and GROWTH can reduce that further, down to 50%.

Offline binTravkin

Re: AI SE changed in patches?
« Reply #8 on: May 18, 2015, 03:50:06 PM »
Btw, from Kyrub's thread on Poly
http://apolyton.net/showthread.php/195007-SMAC-444-%28AI-experiment%29/page4
Quote
SMAX patch has almost NO AI improvement. Just the terraforming basics. Nothing from all the other, important stuff. So you have seen nothing.


Ok, I downloaded OllyDbg and tried to open terranx.exe.
Now I'm looking at large amount of asm code.

How do you proceed from here?
Like, what are your routine tasks to do some change?
Let's say some very small one.
Can't name it because not sure what's "small" in terranx.exe.

I also found some extra info in some of the threads around here and it appeared to be more structured than just a bunch of asm (some function lists, etc).
Do you use any of that?

Offline Yitzi

Re: AI SE changed in patches?
« Reply #9 on: May 18, 2015, 04:26:49 PM »
Ok, I downloaded OllyDbg and tried to open terranx.exe.
Now I'm looking at large amount of asm code.

How do you proceed from here?
Like, what are your routine tasks to do some change?
Let's say some very small one.
Can't name it because not sure what's "small" in terranx.exe.

Basically, my methodology is:

1. Find a "handle" to let me find the procedure relevant to what's going on.  (At first, my "handles" were plaintext strings; once I learned where some important functions and variables were, I was able to use a lot of those instead, but I still often use plaintext.)

2. Analyze the procedure.

3. Design the necessary change.

4. Make the necessary change.

Quote
I also found some extra info in some of the threads around here and it appeared to be more structured than just a bunch of asm (some function lists, etc).
Do you use any of that?

I think I discovered and wrote up most of that...which is why I don't think there's any AI stuff in there...

Offline Dio

Re: AI SE changed in patches?
« Reply #10 on: May 26, 2015, 03:55:16 PM »
I am currently working on deciphering several areas in which diplomatic relationships, faction AI mandates, AI unit plans, and governor options interact with each other. In addition, I have begun keeping records in a text file of my findings and the addresses at which they occur. Hopefully this will help create more handles for all .exe coders to work with on future projects.

Offline kyrub

Re: AI SE changed in patches?
« Reply #11 on: July 07, 2015, 04:42:01 PM »
My latest AI SE version for smac has become very succesful (before it was the contrary). Limitted, but working much better than original. AI checked for number of offensive planes before running ---Police etc.

I did not port anything from it to smax, I am afraid.

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

You waited so long to heed us, earthdeidre,
Almost we pruned you, as we may yet prune your branches.
~Lady Deirdre Skye 'Conversations With Planet'

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 41.

[Show Queries]