Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Weighted Random Numbers


    Hyper Crusher

    Recommended Posts

    This is just a simple utility that offers random numbers within a range, with the option to provide a bias.

    When working on scripts I prefer to have the bot wait between 600-900ms if an action has been completed or after opening the bank for example, rather than always waiting the same amount of time I like to choose a random number between these. I also prefer to have a bias applied since an even distribution is inhuman in nature and anything that says "I am a bot" is something I would like to avoid. The class can be included anyway in your project, all of the methods are static so you do not need an object instance to call them.

    All functions return int

    Unbiased

    To clarify this is just a wrapper for  java.util.Random().nextInt((max - min) + 1 ) + min;

    Random.nextInt(int min, int max);

    Lower 'weight'

    Random.low(int min, int max);

    Mid-point 'weight'

    Random.mid(int min, int max);

    Higher 'weight'

    Random.high(int min, int max);

    Custom 'weight'

    for reference deviation for all functions is 0.3 of the difference of max and min

    Random.nextGaussian(int min, int max, double deviation, double mean);

    Data set

    I ran all functions 20,000 times, and plotted the points on a graph. X-axis is the number generated and the Y axis is the number of times that number showed up

    Low Bias:

    image.thumb.png.a37c9e3a43d1e382bec690de7b4e5182.png

    Mid-point Bias:
    image.thumb.png.e97e4d55fea389873df958950318cc2a.png

    High bias
    image.thumb.png.05d696d54430c67b248d0d59a8a6b2eb.png

    Random.java

    Link to comment
    Share on other sites

    Eh,  still random enough they just have a tendency to be a higher or lower average. It doesn't prevent 99 from being hit on low for example the bias is just a subtle difference to avoid a even average :)

    Link to comment
    Share on other sites

    You can also use Gaussian random if bias is what you are seeking. Its probably even more natural

    // From 300 to 900 with "bias" of 600
    Calculations.nextGaussianRandom(600,300);

     

    Link to comment
    Share on other sites

    On 11/7/2019 at 6:20 AM, Neffarion said:

    You can also use Gaussian random if bias is what you are seeking. Its probably even more natural

    
    // From 300 to 900 with "bias" of 600
    Calculations.nextGaussianRandom(600,300);

    That does work, but I personally prefer being able to set lower, and upper limits :)

    if your looking for just a way to ensure a bias towards one number or another it works great though. I want to eventually do it with a Gaussian function, but for some quick goings this is working reasonably enough. I'm new to DreamBot, so I'm still fumbling my way through the API and testing different features :)

    Link to comment
    Share on other sites

    I can't seem to figure out how to edit the main post, (or my reply where I merged my response and the quote, my bad)

    So here is an update :D

     

    I went ahead and decided that normal distribution was the way to go, so I spent some time working out a deviation and mean that I think worked with what I was trying to go for when I quickly wrote this up
     

    main post now reflects this update

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.