• 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.
I would love a mathematical answer to this question. I have tried to track it down in the code a couple of times but haven't found it. The weight, I think, is used to make simple probabilities. If you add up all of the weights you get the denominator. Then you use the weight number for each item in the numerator. Then you have a simple percentage chance for each item to show up. I think the rarity value for items is used in this as well, but I don't know how.

0 defines it as being always available.
 
Well, Im not sure I understand how that works. Some weights of 50 I see should show up more than items with a smaller weight, yes? But they do not. I'm not sure how rarity works... or how "count" factors in.

Edit, just saw an item with a weight of 75. With that much weight, it should have a higher percentage than other items to show, yes? But these items with that weight are supposed to be rare. Their rarity is only 5 and I have seen rarity as high as 20. I'd love to know how this works. I'm trying to decide what weights to give things so the shops arent all out of whack.
 
thinking the weight is reverse
0 being the most common and 20 being the most rare.

Given what I saw looking at it item by item, I'd have to agree -- 0 is "common as dirt on a planet", and 20 is "we deny this ever existed".
 

Take a stroll through the default files for the cockpit upgrades, and note that the better versions have higher rarity values.

Look through the LosTech items... they all have the highest rarity value I've found, which is 20.

In contrast, the standard versions of the basic 3025 weapons have a rarity value of 0.

I don't think it would make sense for the better or more exotic items to have rarity values that would make them more common in the game.

Therefore, I have to conclude that 0 = common, 20 = rarest of the rare.
 
Take a stroll through the default files for the cockpit upgrades, and note that the better versions have higher rarity values.

Look through the LosTech items... they all have the highest rarity value I've found, which is 20.

In contrast, the standard versions of the basic 3025 weapons have a rarity value of 0.

I don't think it would make sense for the better or more exotic items to have rarity values that would make them more common in the game.

Therefore, I have to conclude that 0 = common, 20 = rarest of the rare.
Yes, you are right. The rarity scale goes up like that. The higher the number, the rarer the item. I just don't think this value is used by stores. I think it is only used for salvage distribution.
 
So weight is used exclusively for stores? Then why would mechs have rarity? Their salvage is determined by an entirely different method. How high can weights go? Anyone know how this is based on the number of shop picks, say if the simgameconstant were set at 100 shop items... are the entirety of the shop weights taken into account for that particular requirement and exclusion tagset and calculated to leverage against the shop item limit?
 
I have found the code so now I can give an exact answer for weights in shops.

  1. It does work as hypothesized. Only weights matter as defined in the shop files.
  2. It creates a sum of all of the weight values for these items.
  3. Then, for each special that the shop is allowed (as defined by its max specials value), it generates a new item. It queries the item list in order and checks to see if that item gets added.
  4. The algorithm for this is simple, yet subtle in its ordering preference. It always starts from the top of the list and works its way down. It follows this logic:
It takes the summed value of all of the weights in the shop file. It generates a random number from 0-1 and multiplies it times this total value of weights.

It then looks at the list in order. For each item, it takes its weight value and sees if it is larger than these randomized value from all of the weights. If it is, the item gets added to the shop. If the item is already there, it just adds more of the same item based upon its "count" value. If the weight is lower than the randomized value, it adds that items weight value to the next item in line and checks if this new weight value hits the threshold. If it does, it gets added to the shop. If not, it continues adding this weight value until an item is added...

It continues to do adding over and over until it reaches the limit of allowed specials. It always starts over from the top of the list every time.

The MAJOR take away from this is that the adding of items is percentage based with an order dependence. The items at the top off the list will always be more favored than lower on the list.
 
I have found the code so now I can give an exact answer for weights in shops.

  1. It does work as hypothesized. Only weights matter as defined in the shop files.
  2. It creates a sum of all of the weight values for these items.
  3. Then, for each special that the shop is allowed (as defined by its max specials value), it generates a new item. It queries the item list in order and checks to see if that item gets added.
  4. The algorithm for this is simple, yet subtle in its ordering preference. It always starts from the top of the list and works its way down. It follows this logic:
It takes the summed value of all of the weights in the shop file. It generates a random number from 0-1 and multiplies it times this total value of weights.

It then looks at the list in order. For each item, it takes its weight value and sees if it is larger than these randomized value from all of the weights. If it is, the item gets added to the shop. If the item is already there, it just adds more of the same item based upon its "count" value. If the weight is lower than the randomized value, it adds that items weight value to the next item in line and checks if this new weight value hits the threshold. If it does, it gets added to the shop. If not, it continues adding this weight value until an item is added...

It continues to do adding over and over until it reaches the limit of allowed specials. It always starts over from the top of the list every time.

The MAJOR take away from this is that the adding of items is percentage based with an order dependence. The items at the top off the list will always be more favored than lower on the list.


That makes tweaking the appearance rate of items in the stores REALLY tricky.

E -- also explains some of the oddness I'm seeing in my attempts to build a "megastore" at one of the independent planets.
 
Last edited:
Yep, but now we at least know what has to be done. Before we were just shooting in the dark. Now we have the power of math on our side. :)
 
Explain the 'in order' part. Where and how does the list order itself?

Within each shop file, for starters -- it's a series of entries in the JSON files.

How it orders multiple files when a planet qualifies for more than one, I don't know.
 
Critical side-question:

Presumably this is *also* the way the game calculates hit locations. If the Head location is moved from the start of the list to the end of the list, will this result in a significant reduction?
 
Critical side-question:

Presumably this is *also* the way the game calculates hit locations. If the Head location is moved from the start of the list to the end of the list, will this result in a significant reduction?

Could it really be this simple?
 
Critical side-question:

Presumably this is *also* the way the game calculates hit locations. If the Head location is moved from the start of the list to the end of the list, will this result in a significant reduction?
That's... Huh. I'm going to look at the code.
 
That is how it works, yes.