Page 1 of 1

Evolution factor and bitters

Posted: Mon Mar 24, 2014 2:32 pm
by slay_mithos
Hello,

While trying to figure things out with bitter spawn mechanisms, regarding the evolution factor, I understood a few things, but a few others remain confuse.

Mainly, there is the question about the max value for this factor.

Because if the max happens to be 1, then it means that any and every mod adding bitter needs to take the other ones into account.

For example, both Dytech and MoCombat add their bitter(s).

If we just add the bitter entry to the spawners, it makes the total required evolution factor higher than 1, and if it caps at 1, any bitter past that limit will never be seen.

If it happens that the max is actually 1, I would go ask for a change in the way things are put together, putting a "min-evolution" into the actual bitter entity instead, which would make the whole system a whole lot more streamlined, and allow for mods to add their bitters regardless of what vanilla or other mods add.

Re: Evolution factor and bitters

Posted: Wed Mar 26, 2014 3:57 pm
by FreeER
Hm, there is a very good point here (yes 1 is the max for evolution factor)...but you might also notice that both MoCombat and DyTech (at this time) overwrite the biter-spawner's result_units, so you're only getting one set of biters anyways.
However, do note one other (more useful and positive) factor. The spawn shift of the spawner is added to the evolution factor (DyTech sets this to be 0.65) so the actual value used in spawning CAN be higher than 1 (it's a random number * (spawn_shift+evolution_factor)).
slay_mithos wrote:putting a "min-evolution" into the actual bitter entity instead
That's basically what you are doing from what I can tell. The C++ code to select the spawned biter is equivalent to:

Code: Select all

function SelectBiterToSpawn(spawnValue, enemyList)
  local sum=0
  for i=1, enemyList.length do
    sum=sum+enemyList[i].weight
    if spawnValue <= sum then return enemyList[i].name end
  end
end
To me it seems like Factorio could/should do some extra work 'behind the scenes', meaning:
modders insert unit and desired evolution factor and then after all mods are loaded Factorio calculates the weights in such a way as to give them a value close to what was desired. Something like: provided_weight/(sum of all provided weights).

ex1: {"small-biter", 0.50}, {"explorer-biter", 0.30}, {"spitting-biter", 0.20}, {"armored-biter", 0.20}, {"cautious-biter", 0.20}
is: {"small-biter", 0.35}, {"explorer-biter", 0.21}, {"spitting-biter", 0.14}, {"armored-biter", 0.15}, {"cautious-biter", 0.15}.

ex2: {"small-biter", 0.50}, {"explorer-biter", 0.50}, {"spitting-biter", 0.20}, {"armored-biter", 0.20}, {"cautious-biter", 0.20}
is: {"small-biter", 0.31}, {"explorer-biter", 0.31}, {"spitting-biter", 0.12}, {"armored-biter", 0.13}, {"cautious-biter", 0.13}

It could also be calculated by dividing the weight of units with equal weights by the number of units with that weight and then dividing everything by the sum of the weights (of all units) (or calculate the sum of all unique weights before equalizing, should be the same as equalizing and them summing all weights).
ex1: {"small-biter", 0.50}, {"explorer-biter", 0.30}, {"spitting-biter", 0.066}, {"armored-biter", 0.067}, {"cautious-biter", 0.067}
ex2:
stage1 (equalizing) : {"small-biter", 0.25}, {"explorer-biter", 0.25}, {"spitting-biter", 0.066}, {"armored-biter", 0.067}, {"cautious-biter", 0.067}
stage2 (divide by .7) : {"small-biter", 0.36}, {"explorer-biter", 0.36}, {"spitting-biter", 0.094}, {"armored-biter", 0.095}, {"cautious-biter", 0.095}