• 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.

GauHelldragon

Sergeant
14 Badges
May 29, 2016
56
25
  • Warlock: Master of the Arcane
  • Cities: Skylines
  • Pillars of Eternity
  • Knights of Pen and Paper 2
  • Stellaris
  • Tyranny: Archon Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Shadowrun: Dragonfall
  • Crusader Kings II
I'm a little confused how the "weight_modifier factor" works when applied to a probability weight.

The AI weight to research missile1 technology looks something like this:
Code:
weight_modifier = {
        factor = 0.50
        modifier = {
            factor = 0.65
            has_ethic = ethic_fanatic_pacifist
        }
        modifier = {
            factor = 0.8
            has_ethic = ethic_pacifist
        }
        modifier = {
            factor = 1.25
            has_ethic = ethic_militarist
        }
        modifier = {
            factor = 1.5
            has_ethic = ethic_fanatic_militarist
        }
        modifier = {
            factor = 1.25
            research_leader = {
                area = physics
                has_trait = "leader_trait_expertise_rocketry"
            }
        }

Seems pretty straight forward. It looks like it's multiplying the base weight by the factor. But then I look at the AI personality files and I see this:
( AI weight modifier for evangelising_zealots )

Code:
weight_modifier = {
        weight = 10
        modifier = {
            factor = 2
            has_ethic = "ethic_fanatic_spiritualist"
        }
        modifier = {
            factor = 2
            has_ethic = "ethic_fanatic_collectivist"
        }       
        modifier = {
            factor = 1
            has_trait = "trait_conformists"
        }
        modifier = {
            factor = 1
            has_trait = "trait_charismatic"
        }
        modifier = {
            factor = -1
            has_trait = "trait_repugnant"
        }       
    }

What effect is a factor of "1" supposed to have here? What about a "-1" ?
 
Factor is the multiplier, how larger the weight is how more likely its going to pick it. Tried to explain it below with added comment.

I'm a little confused how the "weight_modifier factor" works when applied to a probability weight.



Seems pretty straight forward. It looks like it's multiplying the base weight by the factor. But then I look at the AI personality files and I see this:
( AI weight modifier for evangelising_zealots )

Code:
weight_modifier = {
        weight = 10
        modifier = {
            factor = 2              #has a weight of 20
            has_ethic = "ethic_fanatic_spiritualist"
        }
        modifier = {
            factor = 2             #also 20 so its changes are equal of the previous one.
            has_ethic = "ethic_fanatic_collectivist"
        }     
        modifier = {
            factor = 1            #weight is 10 so half of the 2 before. So less likely to be picked.
            has_trait = "trait_conformists"
        }
        modifier = {
            factor = 1           #same as above
            has_trait = "trait_charismatic"
        }
        modifier = {
            factor = -1           #   -10 negative from what think it will never get picked
            has_trait = "trait_repugnant"
        }     
    }

What effect is a factor of "1" supposed to have here? What about a "-1" ?
 
As I understood it each valid factor should multiply weight in succession. So if somehow all of those factors applied it would be: 10 * 2 = 20, then 20 * 2 = 40, then 40 * 1 = 40, then 40 * 1 = 40, and finally 40 * -1 = -40.

Mind, I'm basing this off the CKII version so it could be wrong entirely because of differences, and even then I had problems wrapping my head around it so the only thing I knew 100% was that a factor of 0 that matches anywhere in the list would nullify the whole thing.
 
As I understood it each valid factor should multiply weight in succession. So if somehow all of those factors applied it would be: 10 * 2 = 20, then 20 * 2 = 40, then 40 * 1 = 40, then 40 * 1 = 40, and finally 40 * -1 = -40.

Mind, I'm basing this off the CKII version so it could be wrong entirely because of differences, and even then I had problems wrapping my head around it so the only thing I knew 100% was that a factor of 0 that matches anywhere in the list would nullify the whole thing.
So then what? It adds all those results together to get the final weight? That makes sense for the second example but then the first one, with the technologies, doesn't make any sense.
 
It makes one big equation. With the tech one the result if you somehow had all the modifiers would be, 100 (The base weight for tier1weight1 stuff) * .5 = weight 50, then 50 * .65 = weight 32.5 etc.

EDIT: I don't know why some places the base weight is set inside weight_modifier and in others it is set outside. Maybe it is because both chance of draw and AI selection is based off the same base weight with techs? *shrug*
 
It makes one big equation. With the tech one the result if you somehow had all the modifiers would be, 100 (The base weight for tier1weight1 stuff) * .5 = weight 50, then 50 * .65 = weight 32.5 etc.

Ok yes this makes total sense for the first one, but when you apply the same thing to the AI personality stuff it is boggling.

Code:
        modifier = {
            factor = 2
            has_ethic = "ethic_fanatic_spiritualist"
        }
This reads "If they have the ethic fanatic spirtualist, the weight is multiplied by 2." Ok, I'm with the logic so far.

Code:
        modifier = {
            factor = 1
            has_trait = "trait_conformists"
        }
This then reads "If they have trait conformists, then the weight is multiplied by 1." ... Well then that would do absolutely nothing.
Code:
        modifier = {
            factor = -1
            has_trait = "trait_repugnant"
        }
This one reads "If they have repugnant trait, then the weight is multiplied by -1." Ok now they have a negative weight. Which basically makes no sense.
 
*shrug* Yeah I'm not sure what the negative weights are; To my knowledge they are completely new to Stellaris. Factor = 1 is precisely the part that has always confused me most, either there is something I'm not getting, or they are leftovers from earlier in development that have since been tweaked out to be meaningless.
 
Weights are comparative, right?

So in the case of personalities, the weight of Evangalizing Zealots is compared to the other personality weights and the highest value wins. In this scenario, a negative weight makes sense (functionally at least).
 
Weights are comparative, right?

So in the case of personalities, the weight of Evangalizing Zealots is compared to the other personality weights and the highest value wins. In this scenario, a negative weight makes sense (functionally at least).
No. Weights are used when it randomly picks from a list of things. The higher the weight, the more likely it is for that option to be picked.
If it always just picked the highest weight, then there would be no randomness at all in things like tech choices, and you would never actually get rare techs.

The weight is sort of like the number of chances something has to be picked. So if you have one option with a weight of "10" and one option with a weight of "1", the first option is ten times more likely to be picked than the second option. This is why having a negative weight makes no sense.
 
Don't assume that weights are used consistently across the game. Different systems will not have the same requirements and thus may not treat the data equivalently, even if the terms are the same. For example, i know for a fact that in 00_deposits.txt you can override a weight entirely via modifier, but afaik this is the only place this is possible.
 
No. Weights are used when it randomly picks from a list of things. The higher the weight, the more likely it is for that option to be picked.
If it always just picked the highest weight, then there would be no randomness at all in things like tech choices, and you would never actually get rare techs.

The weight is sort of like the number of chances something has to be picked. So if you have one option with a weight of "10" and one option with a weight of "1", the first option is ten times more likely to be picked than the second option. This is why having a negative weight makes no sense.
I'm not sure I agree with weight referring to likeliness. I think it's simply the highest (or maybe the lowest in some cases) because, at least in the case of personalities, it appears to be one of the last 'choices' made when creating an empire. By the time personality is chosen, ethics and traits (at least) have already been chosen according to their weights. You don't really need randomness this far into the creation process.

As for tech choices, I still don't think there's randomness involved, mostly because of the same idea as personalities. By the time you get 3 tech alternatives to pop, those techs have already been filtered through different modifiers. What looks like randomness isn't.

Don't assume that weights are used consistently across the game. Different systems will not have the same requirements and thus may not treat the data equivalently, even if the terms are the same. For example, i know for a fact that in 00_deposits.txt you can override a weight entirely via modifier, but afaik this is the only place this is possible.
00_country_types seems to work similar to 00_deposits... you can replace the original value with a modified value. I'm pretty sure that's also what's happening in the missle tech example above.
 
I'm not sure I agree with weight referring to likeliness. I think it's simply the highest (or maybe the lowest in some cases) because, at least in the case of personalities, it appears to be one of the last 'choices' made when creating an empire. By the time personality is chosen, ethics and traits (at least) have already been chosen according to their weights. You don't really need randomness this far into the creation process.

As for tech choices, I still don't think there's randomness involved, mostly because of the same idea as personalities. By the time you get 3 tech alternatives to pop, those techs have already been filtered through different modifiers. What looks like randomness isn't.

I have run the game using pre-set AI Empires, and they do not always use the same personality every game. So yes, there IS some randomness to this choice.

Tech choices are absolutely random too. Don't take my word for it though, use the console command "techweights phy". (physics in this example). It will show you exactly what tech options there are for your empire currently, their weights, and their associated probability. It does not just pick the 3 with highest chance, and you can see that by comparing your 3 options to the list it provides.
 
Last edited:
I have run the game using pre-set AI Empires, and they do not always use the same personality every game. So yes, there IS some randomness to this choice.

Tech choices are absolutely random too. Don't take my word for it though, use the console command "techweights phy". (physics in this example). It will show you exactly what tech options there are for your empire currently, their weights, and their associated probability. It does not just pick the 3 with highest chance, and you can see that by comparing your 3 options to the list it provides.

You're right. Presets (ie procedurally generated) don't and won't be the same everytime. However, that doesn't mean that randomness is necessary at the Personality level. There simply needs to be a way to seperate outcomes at the very first stepThis could be a random "dice roll" of sorts, or it could be weights and limits. But after that, randomness is no longer necessary and the highest weight can take over and empires will still appear to be random.

Does anyone know the first file used to create preset empires is?
 
You're right. Presets (ie procedurally generated) don't and won't be the same everytime.?

No, i do not mean procedurally generated empires. I mean empires that I created and are exactly the same every time. They have the same goverment, the same ethics, the same race every time. But the AI personality it assigns to them at the start of the game is NOT the same every time.

Does anyone know the first file used to create preset empires is?
Preset, non-random AI empires are in /Stellaris/prescripted_countries/00_prescripted_countries.txt
 
Negative weights have been used in lots of Paradox games. Usually with bad results tbh.

The effect is basically the same as factor = 0, in that something with a negative weight has 0% chance of being picked. Unfortunately, if you have another negative factor, then a negative * a negative becomes a positive... leading to unexpected results.

Stellaris tech AI is basically the same as Vicky 2's - it's officially called a random weighted array, and it works more or less exactly as GauHelldragon suggests.
 
Ah, I see what you're saying. Interesting.

Now I'm curious about how weight = { differs from weight_modifier = {

If highest level entries in Personality are all weight_modifier then it has to be modifying weight somewhere, right? And if that weight value is not contained within Personalities, then it's elsewhere? If this weight value is random or somehow modified by non-Personality values, then there's your randomness.


Edit: Ah, thank you Naselus.