Role Weights and System Populator Run Times

General discussion for players of Oolite.

Moderators: another_commander, winston

Post Reply
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 519
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Role Weights and System Populator Run Times

Post by Nite Owl »

Had a good long look at the Role Weights of the core ships, Griff's ships, and the many OXZ/OXP ships that inhabit my Ooniverse. Been doing this because many of the particularly nice looking OXZ/OXP ships have not been showing up with enough regularity to satisfy me. Fairly sure my understanding of how the Role Weights work is correct. As an example of where my current thoughts have lead me. If my Ooniverse has 10 ships with the variable role = "pirate"; (note lack of any weight numbers in parenthesis) then each of these ships has a 1 out of 10 chance of being called by the System Populator to create a Pirate Ship when a system is created. If role = "pirate (#)"; is used then the number in the parenthesis would change that 1 out 10 chance based on the positive (>1) or negative (<1) effect of that number.

Would giving all of the ships in my Ooniverse a Role Weight of role = [whatever role]; with no additional numbered weight in parenthesis cause the System Populator Run Times to increase by any significant amount? Currently this takes about 1 second with the very large amount of OXZ/OXP's that my Ooniverse consists of.

Thank You in advance for any and all answers.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Role Weights and System Populator Run Times

Post by Switeck »

It could be a relative weight instead of absolute -- you have to consider ALL other ships' role weights before determining the odds of a particular ship appearing.
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Role Weights and System Populator Run Times

Post by Alnivel »

It shouldn't affect a populator run time significantly (or even at all) - if a role has no explicitly specified weight, it has an implicit 1.0 weight.

When the game loads ships, it creates probability sets for each role - essentially a list of shipkeys and their weights. When the game tries to create a ship in the role it rolls a random number in the range [0; total sum of all weights in the set), and searches in the list shipkey with the lowest commutative weight (weight of shipkey in the role plus sum of weights of previous shipkeys) that is greater than the random number.

There is no special treatment for roles with explicit or implicit weights and whether all ships have the same weight or not doesn't matter too.


What can significantly affect a populator run time is a lot of ships with conditions/condition scripts that often forbid spawning - if the first rolled ship cannot be used the game creates a copy of the probability set and starts to reroll ships and remove them from the set, if it can't be used too, until the game finds one that pass conditions or the set run out of candidates.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1377
Joined: Thu Aug 27, 2015 4:24 pm

Re: Role Weights and System Populator Run Times

Post by cbr »

Alnivel wrote: Sun Sep 24, 2023 11:28 am
What can significantly affect a populator run time is a lot of ships with conditions/condition scripts that often forbid spawning - if the first rolled ship cannot be used the game creates a copy of the probability set and starts to reroll ships and remove them from the set, if it can't be used too, until the game finds one that pass conditions or the set run out of candidates.
Which oxp (with populator and/or condition scripts ) will then take precedence?
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Role Weights and System Populator Run Times

Post by Alnivel »

cbr wrote: Sun Sep 24, 2023 6:05 pm
Alnivel wrote: Sun Sep 24, 2023 11:28 am
What can significantly affect a populator run time is a lot of ships with conditions/condition scripts that often forbid spawning - if the first rolled ship cannot be used the game creates a copy of the probability set and starts to reroll ships and remove them from the set, if it can't be used too, until the game finds one that pass conditions or the set run out of candidates.
Which oxp (with populator and/or condition scripts ) will then take precedence?
Sorry, I don't understand the question, could you please elaborate?
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1377
Joined: Thu Aug 27, 2015 4:24 pm

Re: Role Weights and System Populator Run Times

Post by cbr »

If you have many oxp/oxz installed with ships and conditions and populators,

which script will be eh dominant?
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Role Weights and System Populator Run Times

Post by Alnivel »

It's not like there is the one and only condition script for all ships, each shipdata entry can have its own condition script. If there are multiple overrides for one entry, the latest loaded wins. And you can have multiple scripts with a populator function, if they set the same populator key, one that sets the latest will prevail, but otherwise they not meddle with each other.
Post Reply