User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21

Thread: Random option with different probability

  1. #11
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by casleziro View Post
    @AftPeakTank perfectly valid solution. I think it gets messy if you want many items, since fitting them all into 100 while also having decent weights is difficult. For something as small as the example, there's no reason you shouldn't use this method if you prefer.

    a note though: reading from counters is slower than reading from an active's alterable value! I see counters used a lot around the forums so I figured I would mention it.
    @casleziro , I bet one can automate it to do as many weights you want. All you have to do is to use the sum of the odds instead of the 100% percentage.

    It really is quite simple.

    You do a random pick from 1 to "the sum of the odds" and you check with a loop so many times as the number of weights you want to have, to see in which range of numbers you are in. Then you apply your result.

    By the way, I used the counter so one could see visualy how it works. This code can of course work in any type of values.

  2. #12
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    The sum method you're describing is similar to what I used in post #6.

    Instead of comparing if you are in a range of numbers, the weight of each item is subtracted from the random pick from 1 to "sum of the odds" until it reaches 0. The loop is then broken and the current item returned. One comparison for each item is likely faster than multiple. But there are many ways to skin a cat, as the saying goes.

    @Volnaiskra got me thinking of ways my method could be sped up even further. I think using an array with 2 y indexes (actual item and item weight) would be faster, or maybe 2 alterable value "containers" like he used in his optimization! Tokenizing a string is surely slow.

    I didn't realize about the counters, sorry @AftPeakTank . I see them used a lot in examples and it irritates me much the same way the list object does

  3. #13
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by casleziro View Post
    The sum method you're describing is similar to what I used in post #6.

    Instead of comparing if you are in a range of numbers, the weight of each item is subtracted from the random pick from 1 to "sum of the odds" until it reaches 0. The loop is then broken and the current item returned. One comparison for each item is likely faster than multiple. But there are many ways to skin a cat, as the saying goes.

    I didn't realize about the counters, sorry. I see them used a lot in examples and it irritates me much the same way the list object does
    Ahh, yes, like you said, looks like...But in the loop I wouldn't do it this way. I would just check for the range with a combo of conditions. I wouldn't loop so many times. Though even like you describe it would be fast enough. Fastloops are really fast.

    Well, I see them too but they are only there for helping purposes...Aren't they?
    hmmmm....
    LOL

  4. #14
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    @casleziro , here is the code I was describing.

    I think it works. You can put as many weights as you want in the active object (works as a holder of values) and you need to update the first Alt. Value with the total number of weights.

    randompick2.png

    Then the following events are doing the job:

    randompick1.png

    You may download the MFA here randompick.mfa

    Second frame holds the current example.

  5. #15
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,558
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    I think @Fenris is going to need a random number generator to decide which of the above methods to use

  6. #16
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    I think @Fenris is going to need a random number generator to decide which of the above methods to use
    Now that was a good one...

  7. #17
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)

    Join Date
    Sep 2018
    Posts
    24
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    @elvisish @Volnaiskra @AftPeakTank @casleziro
    Thanks a ton guys! It's amazing to see how many different approaches there is. I guess I really need a random generator to decide which method to use
    You've been extremely helpful, thank you very much

  8. #18
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)

    Join Date
    Sep 2018
    Posts
    24
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AftPeakTank View Post
    @casleziro , here is the code I was describing.

    I think it works. You can put as many weights as you want in the active object (works as a holder of values) and you need to update the first Alt. Value with the total number of weights.

    randompick2.png

    Then the following events are doing the job:

    randompick1.png


    Second frame holds the current example.

    Even though I will probably go with the simpler examples that will be more than enough for me, I really want to understand what is going in this one Keep in mind, I'm a beginner to coding and fusion, and at this moment I have no idea what this example does I don't understand what the code does. It works like a charm, but I need to know how exactly. And I would really like to figure it out alone, because I think that'll be the best way to learn.

    I have some business to do in the next two days, but when I get back home, I'll bury myself in this example and do my best to figure out what exactly it does and how. If I fail completely then I'd like to ask some more questions if that's ok If I don't reply in a week or two, then I probably figured it out and I thank you very much

  9. #19
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenris View Post
    Even though I will probably go with the simpler examples that will be more than enough for me, I really want to understand what is going in this one Keep in mind, I'm a beginner to coding and fusion, and at this moment I have no idea what this example does I don't understand what the code does. It works like a charm, but I need to know how exactly. And I would really like to figure it out alone, because I think that'll be the best way to learn.

    I have some business to do in the next two days, but when I get back home, I'll bury myself in this example and do my best to figure out what exactly it does and how. If I fail completely then I'd like to ask some more questions if that's ok If I don't reply in a week or two, then I probably figured it out and I thank you very much
    Ahh, happy I helped and you are satisfied. In fact the people in this community are always kind and help as much as possible.

    Of course you may ask anything. Just tag me

  10. #20
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)

    Join Date
    Sep 2018
    Posts
    24
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ok @AftPeakTank I finally figured it out. I'm kind of a math retard, so it took me more time than I'm willing to admit

    I literally took pen and paper and went through the code multiple times to try to figure it out. And I did a rookie mistake thinking that LoopIndex is the number of loops and it gets smaller every time loop runs until I looked it up and learned that it actually goes up with every loop *facepalm*. I can't believe how simple it actually is

    I just have one question. If i would set multiple values to 0, (because the options aren't available at the start of the game, for example) there shouldn't be any problems right? It would just add the 0 to the counter, 1 to LoopIndex and everything else would stay the same. I tried it a couple of times and it seems to work, i just want to make sure

Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. Allow offline option disable. How enable this option?
    By pradeep in forum HTML5 Export Module 2.5
    Replies: 2
    Last Post: 5th March 2015, 10:14 AM
  2. Replies: 0
    Last Post: 14th February 2015, 05:02 PM
  3. Best way to randomize with a probability table
    By Boba Fonts in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 11th August 2011, 06:25 AM
  4. Probability example
    By LB in forum File Archive
    Replies: 1
    Last Post: 18th April 2010, 10:01 AM
  5. Probability Based Events Example
    By Atom in forum File Archive
    Replies: 0
    Last Post: 20th October 2008, 08:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •