Thread: How to get accurate skill success chances for your server.

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 How to get accurate skill success chances for your server. 
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000

    DISCLAIMER!!!! NOT ALL DATA IS RELEASED YET!!!
    ALSO I WROTE NON OF THIS CODE EXCEPT FOR THE EXAMPLE



    The data that the OSRS Wiki team has been crowdsourcing has started to appear on the wiki which means we can take advantage of it and use it for our servers.

    The way OSRS calculates your chance is by interpolating between a low and a high value using your current level to determine the chance.

    So the higher your level the closer you are to the specified high chance value. Your chance at being successful will always be competed against a random number between 0 and 256.

    Code:
        /**
         * Interpolates between a low chance and a high chance
         *
         *     @Param level      The player level
         *     @Param lowChance  The low chance value
         *     @Param highChance The high chance value
         *     @Return The interpolated value / chance
         */
        public static int interpolate(int level, int lowChance, int highChance) {
            return lowChance + (highChance - lowChance) * (level - 1) / 98;
        }
    So how do we find the low and high values? By scouting the wiki!

    Lets take the low and high chance value for harpooning sharks. (https://oldschool.runescape.wiki/w/Raw_shark) When arriving at the page it should by default look like something below.
    Attached image

    Simply scroll down until you see:
    Attached image

    The graph shows you the chance in percantage you have at harpooning a shark successfully from level 77 through 99, that's not what we're after through, we're after the low and high values, so click on the edit source button
    Attached image

    You should at arrive at a page where you can eddit the source, simply look for the low and high values:
    Attached image

    Low val: 3, high val: 40. So how do we use these numbers? Here's an example:
    Code:
            /*The lowest chance val*/
            val low = 3;
            /*The highest chance val*/
            val high = 40;
            /*the players level*/
            val level = 99;
            /*the interpolated chance*/
            val chance = interpolate(level, low, high);
            /*The random number from 0 through 256 the chance val is competed against*/
            val random = new Random().nextInt(256);
            /*if the chance val is higher than the random val, add raw shawk to inventory*/
            if (chance >= random) {
                add(Item.RAW_SHARK, 1);
            }
    Quote Originally Posted by Kris View Post
    Since George hasn't done it yet, I'll add the cascade function as a reply to this thread as well, converted from lua to kotlin for those who might struggle with it.

    Code:
        fun interpolate(low: Int, high: Int, level: Int) : Double {
            val value = floor(low * (99 - level) / 98.0) + floor(high * (level - 1) / 98.0) + 1
            return min(max((value / 256), 0.0), 1.0)
        }
    
        fun cascadeInterpolate(elements: Array<Element>, level: Int, index: Int) : Double {
            assert(elements contentEquals elements.copyOf().sortedByDescending { it.req }.toTypedArray()) { "Elements array is not sorted." }
            var rate = 1.0
            for (i in elements.indices) {
                val v = elements[i]
                if (i == index) {
                    rate *= interpolate(v.low, v.high, level)
                    return rate
                }
                if (level >= v.req) {
                    rate *= 1 - interpolate(v.low, v.high, level)
                }
            }
            throw IllegalStateException("Index out of bounds")
        }
    
        data class Element(val low: Int, val high: Int, val req: Int)
    Example usage:
    Code:
    val successProbability = cascadeInterpolate(elements, playerLevel, indexOfElementInArray)//returns a double from 0 to 1, giving the probability of the given action succeeding.
    Note: When the array of elements is passed to the cascade function, the array must have been sorted in descending order, starting with the highest level element. If they're out of order, you will receive invalid probabilities. All the examples in Wikia I could find had them in descending order, starting with the highest level one. Thus the assertion at the top of the cascade function.

    The formula is, as Scu11 mentioned above, from Skilling Success Chart.
    Last edited by George; 01-14-2021 at 10:06 AM.
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    Attached image
    Reply With Quote  
     


  2. #2  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Keep up the good work
    Attached image
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    rebecca's Avatar
    Join Date
    Aug 2017
    Posts
    1,071
    Thanks given
    862
    Thanks received
    915
    Rep Power
    5000
    nice =]
    Reply With Quote  
     

  4. #4  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,818
    Thanks received
    1,767
    Rep Power
    2438
    How does this differ from what was done previously?
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  5. #5  
    plz dont take my wizard mind bombs Women's Avatar
    Join Date
    Mar 2010
    Posts
    1,881
    Thanks given
    724
    Thanks received
    1,162
    Rep Power
    4763
    really nice contribution George!
    Reply With Quote  
     

  6. #6  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,312
    Thanks received
    691
    Rep Power
    1098
    Well done, simple yet very useful contribution.
    Reply With Quote  
     

  7. #7  
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000
    Quote Originally Posted by Tyluur View Post
    How does this differ from what was done previously?
    What was done previously? I guess the difference is that this is the confirmed method that JaGex uses, and the low/high chances are the most accurate numbers you're gonna get as its been crowdsourced from thousands of people using runelite.
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    Attached image
    Reply With Quote  
     

  8. Thankful user:


  9. #8  
    So when I'm free, I'm free


    Jay Gatsby's Avatar
    Join Date
    Jun 2010
    Posts
    2,307
    Thanks given
    1,148
    Thanks received
    1,982
    Rep Power
    5000
    Nice contribution, keep it up
    Reply With Quote  
     

  10. #9  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Include the cascade function found on wikia as well please.
    Code:
    function interp(low, high, level)
    	local value = math.modf(low*(99-level)/98) + math.modf(high*(level-1)/98) + 1
    	return math.min(math.max(value / 256, 0), 1)	
    end
    
    function cascadeInterp(bounds, level, index)
    	local rate = 1.0
    	for i, v in ipairs(bounds) do
    		if i == index then
    			rate = rate * interp(v.low, v.high, level)
    			return rate
    		end
    		if level >= v.req then
    			rate = rate * (1 - interp(v.low, v.high, level))
    		end
    	end
    end
    Cascade is used when multiple options are possible, for example when fishing shrimps and anchovies.


    Despite shrimp success rate being 100% if you input the values into the interp func, it would still only cap out at 50% due to there being two possible options. Would hate to see servers get the interpolation right but miss out on the multiple option part.
    Good release though!
    Attached image
    Reply With Quote  
     

  11. Thankful users:


  12. #10  
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000
    Quote Originally Posted by Kris View Post
    Include the cascade function found on wikia as well please.
    Code:
    function interp(low, high, level)
    	local value = math.modf(low*(99-level)/98) + math.modf(high*(level-1)/98) + 1
    	return math.min(math.max(value / 256, 0), 1)	
    end
    
    function cascadeInterp(bounds, level, index)
    	local rate = 1.0
    	for i, v in ipairs(bounds) do
    		if i == index then
    			rate = rate * interp(v.low, v.high, level)
    			return rate
    		end
    		if level >= v.req then
    			rate = rate * (1 - interp(v.low, v.high, level))
    		end
    	end
    end
    Cascade is used when multiple options are possible, for example when fishing shrimps and anchovies.


    Despite shrimp success rate being 100% if you input the values into the interp func, it would still only cap out at 50% due to there being two possible options. Would hate to see servers get the interpolation right but miss out on the multiple option part.
    Good release though!
    I had no idea, thanks
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    Attached image
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 3
    Last Post: 03-22-2013, 11:38 PM
  2. Replies: 7
    Last Post: 09-14-2011, 05:19 PM
  3. [GUIDE] How to get SMS+PBP PIN-s for free [5$]
    By Rune-Exclusion in forum Selling
    Replies: 2
    Last Post: 01-13-2011, 07:03 PM
  4. How to get the most performance out of your code
    By thiefmn6092 in forum RS 503+ Client & Server
    Replies: 26
    Last Post: 02-08-2009, 10:51 AM
  5. Replies: 24
    Last Post: 09-15-2007, 04:32 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
  •