• 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 #24 - AI

Hello everyone and welcome to yet another development diary for Stellaris! Today, I'll be talking about AI, and not of the robotic kind. I'm talking of course, of the game AI, which is currently being developed by myself and @merni who is the dedicated Stellaris AI programmer, while I'm just temporarily on the project to flesh out certain aspects of the AI before launch.

Artificial Personalities
A major challenge when making the Stellaris AI has been the randomized nature of the game. With thousands of different combinations of ethoses and traits, there's a risk that every AI Empire ends up feeling the same to the player, or fall into a very basic categorization of 'aggressive aliens' and 'peaceful aliens'. I as the AI programmer might know that an AI with Fanatic Collectivism makes their decisions differently from with plain old vanilla Collectivism, but it might all look the same to a player who doesn't have this foreknowledge.

In order to address this problem, we've implemented a system of AI Personalities that govern almost every aspect of how they behave, such as who they'll pick a fight with, which trade deals they are interested in and how they budget and utilize the resources available to them. This personality is determined by their ethos, government form and traits, and will be shown to the player when diplomatically interacting with that Empire. To feel recognizeable to the player, all of the personalities are rooted in sci-fi tropes, so that you'll immediately know who the Klingons are to your United Federation of Planets.
6ZK8UQS.png


Personalities naturally have a bigger impact on diplomacy than anything else - if your goal is to form a Federation, it'll be much easier to do so with an Empire of Federation Builders than a bunch of Ruthless Capitalists, and forget getting Xenophobic Isolationists to agree to any such proposal unless they have a very pressing reason. You can tell how an Empire feels about you from their Attitude, which is primarily driven by opinion, and affects factors such as what diplomatic offers they'll consider and how fair a shake they will give you in trade deals.
h76nTL1.png


In addition to the regular personalities, there is also a special set of personalities for Fallen Empires. Instead of the usual mix of Ethoses, each Fallen Empire has only a single Fanatic Ethos - the single remaining ideal they hold to after centuries of seeing what the galaxy has to offer. This Ethos determines their personality, which in turn affects how they view your actions. For example, a Xenophobic Fallen Empire will want nothing to do with you or anyone else and will be very upset if you start encroaching on their borders, while a Spiritualist Fallen Empire will consider themselves the protectors of the galaxy's holy sites, and will not look kindly on your colonists trampling all over their sacred planets. If you think angering a Fallen Empire is harmless because they won't conquer you - think again. Fallen Empires get a special wargoal to force you to abandon planets, and will be more than happy to cut your upstart species down to size if you don't show sufficient respect for your elders.
KViqQD9.png


Threats and Rivals
So what then, is a pressing reason for an AI to go against their personality? Well, one such reason is Threat. Threat is a mechanic somewhat similar to Aggressive Expansion in Europa Universalis 4. Conquering planets, subjugating other Empires and destroying space installations will generate Threat towards other Empires. The amount of Threat generated depends both on how far away the Empire is from what's happening and on their Personality. Xenophobic Isolationists won't care if you're purging aliens half a galaxy away, but if all the planets around them being swallowed up by an expanionistic Empire, they'll definitely take note. Empires that are threatened by the same aggressor will get an opinion boost towards each other, and will be more likely to join in Alliances and Federations - if you go on a rampage, you may find the rest of the Galaxy uniting to take you down, and while Threat decays naturally over time, there's no guarantee that the alliances formed by your imperialism will break up even if you take a timeout from conquering... so expand with care.

Another feature borrowed from EU4 to drive AI behaviour is Rivals. Any independent Empire that are you not allied to can be declared a Rival, up to a maximum of 3 Rivals at the same time. Having an Empire as a Rival will give you a monthly increase of Influence, with the amount gained based on how powerful they are relative to yourself - having a far weaker Empire as your antagonist will not overly impress your population. It is further modified by Ethos, with Militarist Empires benefitting significantly more from Rivalries than Pacifist ones (but paying more influence to be part of an Alliance). Naturally, Empires won't be particularly happy about being declared a Rival, and are pretty likely to rival you right back. Having a Rival will improve relations with their enemies and worsen relations with their friends, so the Rivalry system will act as a primary driver of conflict and alliance in the galaxy.
pEIgTBV.png


AI Economics
Finally, I wanted to cover the topic of the AI's bookkeeping. While it may be far less exciting and far less visible to the player than its diplomatic behaviour, having solid economics is one of our biggest priorities for the Stellaris AI, for multiple reasons. Firstly, so that the AI is able to compete reasonably with the player without resorting to outright cheating. True, the AI will never be as good as an experienced player, but there is a big difference between the player being able to outproduce one AI Empire and the player being able to outproduce five of them together. Secondly, because of the Sector mechanic that was covered in DD 21, the AI will actively be making construction and management decisions on the player's planets, and while - again - it will never be as good as an experienced player making the decisions themselves, it needs to be good enough that the player doesn't feel like the AI is actively sabotaging their Empire.

In order to accomplish all this, a huge amount of time has been put into the AI's budgeting system. Every single mineral and energy credit that the AI takes in is earmarked for a particular budget post such as navies or new colonies, with the division between the posts being set according to the AI's personality and what it needs at the time. The AI is only permitted to spend appropriately budgeted resources, so it'll never fail to establish new colonies because it's too busy constructing buildings on its planet, or miss building a navy because mining stations are eating up its entire mineral income. In times of dire need, it can move resources from one budget post to another - if it's at war and its navy gets destroyed, expect it to pour every last mineral into building a new one.

When making decisions about what to construct, the AI looks primarily at what resources it has a critical need for (such as Energy if it's running a deficit), secondarily at what resources it's not producing a lot of compared to what it expects an Empire of its size to produce, and lastly at whatever it deems useful enough for the mineral investment. Sectors have additional logic to ensure they produce more of the resource you've set them to focus on, so an Energy sector will naturally overproduce Energy - you told it to, after all.
12eo2mu.png


Alright, that's all for today. Next week we'll be talking about debris and the fine art of reverse engineering.
 
Last edited by a moderator:
  • 156
  • 128
Reactions:
That's not the point. The point is that British society had changed over the past hundred years to such degree that using excessive force to quell colonial unrest had become... distasteful. Especially if said force was applied against non-violent resistance. Images that made it home of non-violent protesters being beaten resulted in outrage among the British population and politicians. At the same time, Gandhi realized this as a shrewd politician / freedom fighter and therefore picked a way of resistance that would give the British leadership only losing counter strategies. If they used violence, they would lose favor at home, if they ignored it, the movement would only grow.

In the 1800's, Gandhi would have been eliminated early by force or by silent assassination and replaced with a more pliable alternative. If British society had not changed, or society with a less contrary 'civilized and liberal' image of themselves had been the colonial power, non-violent resistance would not have been an option, and the only way to break free would be to use the numbers against them in a violent revolt. It would likely have worked too, even if the losses would have been catastrophic.

Overall: Non-violent resistance work best to produce grand results, when the opposing force is unwilling to use violent means to bring it to an end or will face opposition at home after doing so.
Like I said the brittish starved millions of indians to death to fuel their war effort during Gandhi's lifetime. They were far less progressive than you seem to think.

Also in india the indus valley civilisation existed for a long time with little or no archelogical evidence of war.
 
  • 3
  • 2
Reactions:
The atrocities they could hide from the public or justify with "we're dealing with violent people!" is irrelevant. What I'm talking about is the public self image and how the Indian non-violent resistance affected it when it arose. It was simply not possible for the British administration to keep justifying its colonial empire with the political and cultural development that had happened, not at home and not to the rest of the world, not in the face of such well calculated moves as Gandhi was capable of.

It would not have had the same effect on some other societies and a violent revolt to throw off the oppressors would have been needed.

And again, how did India fare when the Muslims came with a very martial culture? A relatively peaceful ethos only works, insofar as your neighbors play along with it, otherwise you will need an army that is ready to strike hard and fast. Staying clear of declaring war and not being able to fight a war are very different things.

In the galaxy of Stellaris, your neighbors will come in many shapes, and many of them will want to eliminate you, no matter how peaceful you are. "Pacifism", as you've said, does not mean pacifism in the regular sense, because a pacifist country in the real world with militant neighbors would be doomed, it simply means they've put an emphasis on peaceful diplomatic handling of situations and in terms of gameplay mechanics, put more research into productivity (food supply) and quickly become weary of war. Perhaps "peaceful<-->militant" would make more sense in terms of real world terms.

Sweden is not 'pacifist', it is peaceful, and in a sweet position where Russia really does not want it to move closer to NATO, nor have any real interest in invading it, unlike... other nearby territory.
 
  • 2
  • 1
Reactions:
https://en.wikipedia.org/wiki/Moriori_people

Sweden has been in a very useful political climate for the past 200 years. Don't expect the galaxy, which your species encounters to be just the same. If Space Nazis decides that Space Sweden is worth invading, you can't just shout "don't! We're pacifist! You're wasting your time!" and expect it to work.

Also, if another country invaded, Say Denmark claimed their less union partner restored to loyalty, would your army just refuse to shoot and surrender right away? I think you're confusing pacifism with neutrality. Even then, it doesn't matter much, your "neutrality" only works as far as those around you will abide by it.
Perhaps if you have a certain ethos or government type, that is inherently pacifist, there could be some game mechanic that would make you kind of like the switzerland of the world and everybody would be inherently less happy if you get invaded than, say, Iraq. I'd think the modding community would probably pick this kind of thing up
 
Perhaps if you have a certain ethos or government type, that is inherently pacifist, there could be some game mechanic that would make you kind of like the switzerland of the world and everybody would be inherently less happy if you get invaded than, say, Iraq. I'd think the modding community would probably pick this kind of thing up

But Switzerland only really worked because of their location and geography. No great power wanted any other great power to get involved with them. Right now we're spawning in a world where we (Space Switzerland) might be spawned next to Space Aleander-the-Great Greece, Space Roman Empire and Space Mongol Empire. They simply will not care about our view on things, but conquer you because you are there.

Neutrality will not get you far unless you're expansive in other ways, maybe by UPLIFTING AND ENLIGHTENING ALL THE XENOS, maybe by politely asking weak neighbors to join you as vassals and so on... but very likely you may find yourself in need of allies and abandon neutrality.

You can still refrain from declaring wars, and simply dismantle enemies upon victories, and maybe some of the new states will join you voluntarily afterwards. I think there certainly will be much power in focusing on society research.
 
  • 3
  • 3
Reactions:
Yes, and "ghoti" is pronounced "fish" :)
Or the joke my english teacher used to say: "One of my students approached me and asked 'Can you recommend me a good texbook about rules of pronunciation in english'? 'My dear, there are no rules of pronunciation in english.'"

But back on original topic: is there gonna be a personality of ruthless opportunists?

Speaking of english: this quote works out well :)

"The problem with defending the purity of the English language is that English is about as pure as a cribhouse whore. We don't just borrow words; on occasion, English has pursued other languages down alleyways to beat them unconscious and rifle their pockets for new vocabulary."
 
  • 7
Reactions:
But Switzerland only really worked because of their location and geography.

You must not forget though, that the "Swiss" in large part are ethnic Germans, and so the Nazi pro-German movement was less likely to want to attack kin - that's no# 1.

(One can also make a similar argument about Sweden, since they are North Germanic speakers - difference with Norway is....they sided with England.)

Also, Spain's neutrality was respected - of course they shared a similar world view at the time.

#2 - Many Nazi's hid their new...uh, "found" wealth in Swiss banks during and after the war. (On that note, so too do many of today's criminals, politicians, and celebrities - who do not wish to pay taxes).

You might say.....Switzerland has made itself indispensable to the whole world.

Maybe someone can create such a situation in Stellaris by hoarding and distributing rare resources in exchange for protection agreements??? Maybe?
 
Last edited:
  • 2
Reactions:
Speaking of english: this quote works out well :)

"The problem with defending the purity of the English language is that English is about as pure as a cribhouse whore. We don't just borrow words; on occasion, English has pursued other languages down alleyways to beat them unconscious and rifle their pockets for new vocabulary."
That sounds like Pratchett.
 
  • 3
Reactions:
  • 1
Reactions:
Hey Wiz, what would a Fanatical Materialist be?
 
But Switzerland only really worked because of their location and geography. No great power wanted any other great power to get involved with them. Right now we're spawning in a world where we (Space Switzerland) might be spawned next to Space Aleander-the-Great Greece, Space Roman Empire and Space Mongol Empire. They simply will not care about our view on things, but conquer you because you are there.

Neutrality will not get you far unless you're expansive in other ways, maybe by UPLIFTING AND ENLIGHTENING ALL THE XENOS, maybe by politely asking weak neighbors to join you as vassals and so on... but very likely you may find yourself in need of allies and abandon neutrality.

You can still refrain from declaring wars, and simply dismantle enemies upon victories, and maybe some of the new states will join you voluntarily afterwards. I think there certainly will be much power in focusing on society research.

Well, the other way of being space Switzerland is to simply be more trouble than you are worth. Switzerland is still dotted with the bunkers and fortifications built into chokepoints during WWII. If I have territory that would be very expensive to grab, hard to keep, and of not much value, then Space Rome, Mongols, and Alexander are liable to go looking for Space Gaul/China/Persia to conquer instead of me, even if I am right next door, or even surrounded.
 
I think it's stupid from the perspective you take as well, seeing as there is no justifiable reason a country with a population in the hundreds of millions could only field a few generals, or that an interstellar civilization could only maintain a few embassies. That is ridiculous.

But it's justified in context by game balancing. Why is this a bad thing IYO?
Victoria lets you have as many generals as you need, and it works fine. Why is it a balance concern here?

Yes, and "ghoti" is pronounced "fish" :)
Which is disingenous since "gh" only makes that sound at the end of a syllable, o and i only have that phoneme in common in multisyllable words, and "ti" only makes that sound when followed by a vowel.
Or the joke my english teacher used to say: "One of my students approached me and asked 'Can you recommend me a good texbook about rules of pronunciation in english'? 'My dear, there are no rules of pronunciation in english.'"
English has a ton of rules, and tons of exceptions to rules, and tons of obscure dialects where the rules are slightly different but which constitute acceptable alternatives in international English.

you are aware that Ghandi got Lucky that his opponents were the British and not some other group with less qualms about making rivers run red with blood.
Clearly you don't know much of British colonial history.
 
  • 2
  • 1
Reactions:
Clearly you don't know much of British colonial history.
Clearly you're unable to actually parse what was said. Let's pitch Ghandi against the Imperial Japanese, see how non-violence works out. Or maybe the Russians/Soviets. During the last century of imperialism western sentiments changed massively, allowing a pacifist strategy to work. Fact is: attitudes matter, of both parties.
 
  • 3
  • 1
Reactions:
And again, how did India fare when the Muslims came with a very martial culture?
Upwards to 80 million losses since initial invasions according to some sources (assuming they're correct). A 1000 year period but still a lot.

Paradox has the advantage that it can take all the ai-personalities from human history. There isn't an atrocity we haven't committed, there isn't an ideal we haven't strived for.
 
Fanatical miliants reminds me of the Shadows. Vorlorns are a bit hard to pin down. They really got that Rivalry thing going on there.

Fanatical Materialism reminds me of Dust and Spice empires. They must flow. Systems built upon commerce and a monopoly on trade.
 
  • 1
Reactions:
Fanatical miliants reminds me of the Shadows. Vorlorns are a bit hard to pin down. They really got that Rivalry thing going on there.

Fanatical Materialism reminds me of Dust and Spice empires. They must flow. Systems built upon commerce and a monopoly on trade.
Not that kind of materialism, it's materialism as in not religion but science. Basically think richard dawkins in space.
 
  • 1
Reactions:
Not that kind of materialism, it's materialism as in not religion but science. Basically think richard dawkins in space.
Excellent.
 
Paradox has the advantage that it can take all the ai-personalities from human history. There isn't an atrocity we haven't committed, there isn't an ideal we haven't strived for.
Well, we haven't blown up someone else's home planet yet, but I suppose it's only a matter of time before someone does it for real.