Author Topic: A few questions about raceWeights:  (Read 1665 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
A few questions about raceWeights:
« on: December 19, 2022, 06:07:52 am »
I'm trying to make every UFO potentially be crewed by a different set of aliens with an equal chance of any specific race being used.

At first I thought this could be achieved just by using raceWeights: but from what I've read the alien crew race can also be set to match the occupants of the base that launched it.

So as more alien bases are added to the map more non-randomized UFO crews will be generated.

I think that to prevent this the variable genMissionRaceFromAlienBase: can be set to false which will cause all UFOs to use the raceWeights: values to determine their crew instead of using the race of their origin base.

Spoiler:
Code: [Select]
alienMissions:

# [=] Example Mission [=]
  - type: STR_EXAMPLE_MISSION
    points: 0
    genMissionRaceFromAlienBase: false # <-- Now it will pick one of the four below options instead of the base's race
    raceWeights:
      0:
          STR_AQUATOID: 25
          STR_GILLMAN: 25
          STR_LOBSTERMAN: 25
          STR_TASOTH: 25
    waves:
      - ufo: STR_SURVEY_SHIP
        count: 1
        trajectory: P0
        timer: 9000
      - ufo: STR_ESCORT
        count: 1
        trajectory: P2
        timer: 7800
      - ufo: STR_CRUISER
        count: 2
        trajectory: P4
        timer: 9000

I'm unsure of exactly how raceWeights: functions though.

For example when making all aliens have an equal chance of spawning if there are ten different possible entries in the raceWeights: section do the combined values all need to add up to 100%?

Spoiler:
Code: [Select]
alienMissions:

# [=] Example Mission [=]
  - type: STR_EXAMPLE_MISSION
    points: 0
    raceWeights:
      0:
          STR_ALIEN_ONE: 10
          STR_ALIEN_TWO: 10
          STR_ALIEN_THREE: 10
          STR_ALIEN_FOUR: 10
          STR_ALIEN_FIVE: 10
          STR_ALIEN_SIX: 10
          STR_ALIEN_SEVEN: 10
          STR_ALIEN_EIGHT: 10
          STR_ALIEN_NINE: 10
          STR_ALIEN_TEN: 10
    waves:
      - ufo: STR_SURVEY_SHIP
        count: 1
        trajectory: P0
        timer: 9000
      - ufo: STR_ESCORT
        count: 1
        trajectory: P2
        timer: 7800
      - ufo: STR_CRUISER
        count: 2
        trajectory: P4
        timer: 9000

Or should they all be set at 50 for 50% chance of each race being picked?

Spoiler:
Code: [Select]
alienMissions:

# [=] Example Mission [=]
  - type: STR_EXAMPLE_MISSION
    points: 0
    raceWeights:
      0:
          STR_ALIEN_ONE: 50
          STR_ALIEN_TWO: 50
          STR_ALIEN_THREE: 50
          STR_ALIEN_FOUR: 50
          STR_ALIEN_FIVE: 50
          STR_ALIEN_SIX: 50
          STR_ALIEN_SEVEN: 50
          STR_ALIEN_EIGHT: 50
          STR_ALIEN_NINE: 50
          STR_ALIEN_TEN: 50
    waves:
      - ufo: STR_SURVEY_SHIP
        count: 1
        trajectory: P0
        timer: 9000
      - ufo: STR_ESCORT
        count: 1
        trajectory: P2
        timer: 7800
      - ufo: STR_CRUISER
        count: 2
        trajectory: P4
        timer: 9000

Also if each has a 50% chance wouldn't the entries higher on a list have more of a chance of being chosen then the lower ones as the coin toss would need to be lost by the previous entries before later ones are considered for their own shot at 50% odds?

Offline TBeholder

  • Sergeant
  • **
  • Posts: 41
    • View Profile
Re: A few questions about raceWeights:
« Reply #1 on: December 22, 2022, 11:13:53 pm »
At first I thought this could be achieved just by using raceWeights: but from what I've read the alien crew race can also be set to match the occupants of the base that launched it.
...
I think that to prevent this the variable genMissionRaceFromAlienBase: can be set to false which will cause all UFOs to use the raceWeights: values to determine their crew instead of using the race of their origin base.
It’s a Deployment  (Alien Mission) property, rather than global. Otherwise yes: if the given mission has genMissionRaceFromAlienBase: true and raceWeights: are defined, it will use weights, otherwise copy from base.
I'm unsure of exactly how raceWeights: functions though.
Weights are relative, so p = W(this)/ΣW(all).
If all weights add up to 100, then it is the same as percentages. If they add up to something else, corresponding portion is considered.
So [0, 50, 35, 15] adds up to 100 and corresponding chances are 0/100, 50/100, 35/100 and 15/100 = 0%, 50%, 35% and 15%.
Similarly [1, 1, 1, 1] adds up to 4 and corresponding chances are 1/4, 1/4, 1/4 and 1/4 = 25%, 25%, 25% and 25%.
…and if you want percents, you don’t need to do normalize these numbers after every tweak, just when you are finished adjusting them. So, less bother for everyone.
For example when making all aliens have an equal chance of spawning if there are ten different possible entries in the raceWeights: section do the combined values all need to add up to 100%?
You do not have to, but may find it more transparent if Weights are readable as % (or ‰) of frequency.
« Last Edit: December 22, 2022, 11:45:56 pm by TBeholder »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: A few questions about raceWeights:
« Reply #2 on: January 01, 2023, 11:07:50 pm »
Sorry about the delay in my response.

Thank you for the detailed explanation it was very helpful.