Announcement

Collapse
No announcement yet.

Weighted Selection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Weighted Selection


    Hi.

    I've generated minerals on this asteroid (a struct)... What would I like to do is randomly pick 3 of those based on a weight. So, nickel is like 75% chance of being found, but platinum is like 2%. Anyone have any suggestions on how to approach this?

    teak


    Last edited by teak421; 08-03-2018, 12:08 AM.
    "A little bit of nonsense now and then is cherished by the wisest men..."
    -- Willy Wonka

    Smooth Zoom Camera Plugin for 4.24 here.


    #2
    When you say pick 3 based on weight, you must envision a scenario where nothing is found since 75% nickel + 3% gold + 2% platinum still gives you only 4/5 chances of finding something, right?

    Unsure if it's 3 or up to 3. If one of the rolls in unsuccessful, should we keep trying?

    I'd add the mineral ores' indexes to an array, shuffle it and then:

    Get index 0,1, 2 -> check which mineral it is -> Random Bool With Weight (chance to find) gives you True / False

    Comment


      #3
      Originally posted by Everynone View Post
      When you say pick 3 based on weight, you must envision a scenario where nothing is found since 75% nickel + 3% gold + 2% platinum still gives you only 4/5 chances of finding something, right?

      Unsure if it's 3 or up to 3. If one of the rolls in unsuccessful, should we keep trying?

      I'd add the mineral ores' indexes to an array, shuffle it and then:

      Get index 0,1, 2 -> check which mineral it is -> Random Bool With Weight (chance to find) gives you True / False
      That's true... Basically, there are three CHANCES to select the minerals... Doesn't mean it will be TRUE. Could be zero on the asteroid... unlikely but possible...

      Thanks... I like it!

      teak
      "A little bit of nonsense now and then is cherished by the wisest men..."
      -- Willy Wonka

      Smooth Zoom Camera Plugin for 4.24 here.

      Comment

      Working...
      X