• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Stellaris Dev Diary #227 - Looking after the AI

KdHFPIxnbfUdecDUWFOFpKrSq3pNeDU6BQdeWWLLCrYe655fAX8gyF_3548erNqCH1DYaMfK8qb7BwsbIZwsd22bEQ3q9jmM7-jKe4dUCd--WO07urWQEkcuT3b-0pJYzWnHB--e=s0


Hello and welcome to a new Dev Diary,

My name is Guido and today I’m here in my role as a Principal Designer on Stellaris to talk about AI in a bit more detail.

You probably have heard about the Custodian Initiative by now which has been created to keep improving the game on a more regular basis and in order to be quicker when reacting to player feedback. A part of this initiative is also to put some more love and attention to the AI of the game going forward - an AI initiative inside the Custodians, basically.

For this, we have set some goals for ourselves going forward:
  1. Always work on AI-related topics, regardless of what else is going on
  2. Move the AI towards being challenging to players in an entertaining way, rather than be optimized to min-max its way to victory
  3. Move the AI towards being more distinctive, so that not all empires feel strong in the same way
  4. Support future DLCs from the get-go
  5. Constantly make small improvements to the AI
  6. React quicker to player feedback
  7. Occasionally make a push for more significant improvements
Speaking of which, for the upcoming patch in November, we have some significant updates in store.

Economic Script Update​


First of all, the biggest change you will notice is how we have changed the economic plans script. This script is the core of the economic behavior of our empires. It defines what resources they strive to get when building districts and buildings. How much population growth they should go for and how much research and unity they want.

The functionality of the script hasn’t changed much, but how we are using it has changed.

Previously the script was divided into early-, mid-and late-game. Depending on the phase of the game, empires would prioritize resources differently. For example, focus on research was lower in the early game than in the later stages of the game. However, this approach didn’t take into account the various situations an empire can find itself in. Especially after a war or when a new empire breaks off an existing one. In those cases, even if the game phase was in the late game, for the respective empires it meant that they were in a much more ‘early game’ position.

uBhcCRICEVI9OQc0U-dQMkvrUuRI9XEsu0KdS3naOfBmz7zMa3jbIVU5q5zwWYshpObGTaTqau-zMAW1SiRcHXYOCNRw1qvq0zbQrPepOEP9jAi1K0kuezFyEsQ0heKhJ84-idbl=s0
LT2BJzggvYTk6h4XYQCGbLlvBzvXZ2PcUyhl3e5myTpzkO2jLqXdCRhIDrs9oUipqiM4uuh89BdjMiW30PUXU2HrXtE3dsHufnJK0TFiAWjZtmRgB2OKmXRzATX-2kNzRJfofA0p=s0


Instead of having 3 different economic plans, we feature 1 base plan instead. In order to get more flexibility and to react to the empire’s situation, we’re relying much more on the ‘subplans’ inside that base plan.

Improved economic subplans​


Subplans can be turned on or off, depending on the situation the empire finds itself in. Our main rationale was to ensure that an empire would be economically stable before it spends resources on ‘bonus’ things like research, population growth, defensive modules on starbases, and unity buildings.

Previously those things were prioritized too early and without enough respect to the basic income of energy and minerals, leading to empires that produced alloys, but had big deficits in energy and mineral production. And this deficit would be the start of an economic death spiral, where the resource debuffs would further reduce production and everything just escalated to the point where an empire was bankrupt on all resources. This became especially problematic after the economic system has been rebalanced to focus resource production more on the districts, rather than the buildings of a planet.

Here’s an example of what the economic situation generally looked for empires in a game that went on for around 80 years:

JkCSTjSHVsY87vJzUb5vNrO_K8aHiUIs6vu-6AQHjeP2sNF_ImdCKwdRaCpSp6mZrqnBSr3eFpfwdu-eUMG-uN16duNFGgaMqw5Ipm4Fd1V4UtwxN5tuTy2X2mEi6_EC_OODtvFb=s0

(These are screenshots from Stellaris version 3.0.3)

Our updated economic script prioritizes basic income first and takes the new economic rebalance into account. Energy and minerals are most important.

The difference between the ‘income’ and ‘focus’ block is that if the monthly income is below what is defined in the ‘focus’ block - districts and buildings which produce those resources get an extra bonus in weight, when deciding what to build.

basic_plan_02.jpg


Then the first subplan kicks in. If a country uses food (therefore, Machine empires will have this subplan turned off) it will prioritize food production.

subplan_1.jpg


The next subplan will check conditions for focusing on consumer goods. Again, checking if the empire actually uses them or not - and then only focus on producing them if the empire has at least a monthly income of minerals of 30.
Based on the fact that in order to create consumer goods you require minerals.
subplan_2.jpg



Further down we activate the plans for prioritizing research and all the higher-level resources

CS9qyuZNW1naD8IG6k1-5GyF-QkYeF_Vw2k9Lugo6rrBtdcFzksDJ2W6X1AHhjHZi44UUkapwAWkaUFBRkvlJ2VxNJp2GQv-6dwBjjCcv86v-sIuInAnfOPr_zYYJzT88QpS51qi=s0


Resulting behavior improvements​


So, the script can check for various situations in AI empires - from the fact if they are a Gestalt Empire, using food to monthly income of specific resources.
This gives the AI a lot more flexibility in managing its economy.

As an example, here we have a 100-year old Galaxy with 13 AIs and every empire is able to manage its economy in a decent enough way. Notice the resource tab at the top - almost all empires have positive income in all resources; the ones with a negative income only have a small deficit:

97IOcqgoSBd3m6c8CQbtqO5z6Yx4XkWopX5HciBdo_4zqVqepRs4QDnnMysgLyute8GQust0nDCT14UMrrSL38p08pcKWHbrvIMbFA8Aj_9WTVpfWVVo8Tw-Qpft6Fi9uJPaSA-c=s0


Apart from this, there were some small, but significant code changes that helped the AI in running the show.

Conclusion​


The code for the AI has been optimized heavily in the past in order to improve performance a lot. However, this has led to some unforeseen and unintended behaviors which have now been corrected. Some of the districts and buildings weren’t considered at all and city districts were weighted way too high. The AI is also now able to build temples and holo theaters, for example.

Finally, the AI has also been given a bit of support in how it will set up its starbases, especially in conjunction with the hydroponics starbase building, which can play a larger role in how you provide food for your empire. The AIs can now use more varied setups when building their starbases, making use of Curator Think Tanks, Nebula Refineries, and other special buildings where it makes sense.

And all of this was built on the foundation of the last major rework of the economic AI, so kudos to @sidestep for making this evolutionary step possible.

With your help, we’re looking forward to giving the AI the attention it deserves and making it even better in the future.

Cheers,
Guido
 
Last edited:
  • 158Like
  • 70Love
  • 14
  • 7
  • 3Haha
  • 1
Reactions:
I really love the Custodians work, but do you guys have an idea of when will the devs start sharing plans for the next actual expansion?


EDIT: wait, what? I just asked a question, why is everybody downvoting?
 
Last edited:
  • 30
  • 12Haha
  • 7Like
  • 2
Reactions:
Thank you for the update!!! I am really happy to see that you take the feedback of the community and take the time to implement a solid solution. I hope it plays as well as it reads :) . Definitely looking forward to it....
 
  • 5
  • 3Like
  • 1Haha
Reactions:
So the Custodians Initiative will now focus on AI: the "AVENGERS INITIATIVE". Well.... If we can't protect the Earth fix Stellaris, you can be damn well sure we'll avenge It!
 
  • 4Haha
  • 1Like
Reactions:
well, two things,
first: why there is in evry subplan since the food one the line "empire_uses_food = no"
second: the screenshot of these 100years old galaxy isn't showing
beside these things it looks really good so far
 
  • 1
  • 1Like
Reactions:
Some of the images seem to be broken and if I open them in a new tab they give Google (?!) error 403. Why they are hosted in some Google server in the first place?

403. That’s an error.

Your client does not have permission to get URL /CS9qyuZNW1naD8IG6k1-5GyF-QkYeF_Vw2k9Lugo6rrBtdcFzksDJ2W6X1AHhjHZi44UUkapwAWkaUFBRkvlJ2VxNJp2GQv-6dwBjjCcv86v-sIuInAnfOPr_zYYJzT88QpS51qi=s0 from this server.

Rate-limit exceeded

Wild guess for the block is adblocker (pihole, ublock origin or such) blocking most Google's tracking scripts and Google's servers getting annoyed when requesting multiple direct linked images.
 
well, two things,
first: why there is in evry subplan since the food one the line "empire_uses_food = no"
second: the screenshot of these 100years old galaxy isn't showing
beside these things it looks really good so far

Think this is a bug with the forums, try this one:

unnamed.gif
 
  • 1
Reactions:
Actual question: does the AI know how to manage and redevelop single planets if need be? For example in the easier difficulties without stability etc. bonuses AI planets often end up lacking amenities because they are not building Holotheathres for example.

Gestalt empires usually require some micromanagement of the Amenities generating jobs because they don't have specialists for that or you end up with not enough them or too much of them so I wonder if AI can handle that as well?
 
  • 15Like
  • 4
Reactions:
Since it's not mentioned in the diary, I'll repeat what I said in a thread recently: I believe that these subplans really need to take Admin Cap into account. Right now, if I understand it correctly, the AI is set to always accept being 10% over cap due to the fact that the merged plan appears to only take one value - which is just bad during any stage of the game.

Early on, running Bureaucrats is very wasteful and limiting, and later on, being 10% over cap results in a huge loss of efficiency, because the penalty is a % of research costs. Fixing those 10% would only require a few Bureaucrats, but it can easily negate the work of dozens of researchers. And the AI is currently seems designed to not even attempt to fix the problem.

The old version where subplans were separated accounted for this and allowed the AI more leeway in the early game, while being more strict later on - similar to what players have generally come to accept is efficient.
 
  • 12Like
  • 3
  • 3
Reactions:
Making sure the AI doesn't completely crash its economy is undeniably a good thing.

But I also hope that the 100 year screenshot was created at normal difficulty.
Otherwise the top AI player having 1k research and 12k fleet power by 2306 would be quite underwhelming.
 
  • 13Like
  • 4
Reactions:
Since it's not mentioned in the diary, I'll repeat what I said in a thread recently: I believe that these subplans really need to take Admin Cap into account. Right now, if I understand it correctly, the AI is set to always accept being 10% over cap due to the fact that the merged plan appears to only take one value - which is just bad during any stage of the game.

Early on, running Bureaucrats is very wasteful and limiting, and later on, being 10% over cap results in a huge loss of efficiency, because the penalty is a % of research costs. Fixing those 10% would only require a few Bureaucrats, but it can easily negate the work of dozens of researchers. And the AI is currently seems designed to not even attempt to fix the problem.

The old version where subplans were separated accounted for this and allowed the AI more leeway in the early game, while being more strict later on - similar to what players have generally come to accept is efficient.
as i remember they working on a change to the admin cap thing, maybe removing it so i don't think it is usefull to add a change to AI behavour on that part before the work on admin cap reaches a point where they know if its stays and how it changes
 
  • 6
  • 2Like
Reactions: