Algorithm RNG that progressively gets harder the higher the number
I currently need a way to create random number generation that gets progressively harder the higher the number..
example: You have the chance of getting a number 0-10. You are most likely to get 1, less likely to get 2, even less likely to get 3 and so on. Does anyone have any suggestions on how to do where it would be progressively harder each number you go up or would my best bet be to do a bunch of logic checks to see if a random number is within a set range and iteration lessen the the gap that allows it to proceed to the next iteration until I've hit the whatever the max number? |
Sounds a bit like "normal distribution", or "the bell curve." You can generate numbers that act like that using the "Box–Muller transform." Look up these things.
My attempt at implementing it in GScript: PHP Code:
If you know in advance that you only need numbers 1 through 10 it's probably easier to do it another way. |
Quote:
|
I'll take a look at it when I get home and see if I can get a general understanding on what he provided and if not I'll take you up on that probably.
|
wow i'm bad with statistics. apparently you can transform your rand()'s uniform distribution into a desired distribution via the latter's quantile function which is the inverse of the cumulative distribution function which is the integral of the probability density function and you could pick something like 2*(1-x) as your density function (for 0<=x<1, i guess the idea is that it's normalized). then wolfram alpha gives 1-sqrt(1-x) (the + solution sounds useless i dunno). so you'd transform the uniform 0<=x<1 rand() into a number between 0 and 10 by doing (1-sqrt(1-rand()))*11 and rounding down.
i guess if 1-x doesn't appeal to you as a distribution you can do the whole thing with stuff like 1-sqrt(x) and 1-x*x and that sort of thing and see if something cool happens but wow i hate statistics. |
Quote:
|
Good seeing you as usual Loriel.
|
I was trying to do something to where the chance exponentially gets higher or lower, but it seems the Math.pow(int, int) function no longer is in working fashion.
|
going off loriel's post... I came up with:
PHP Code:
PHP Code:
|
Quote:
|
This sounds interesting. Would defiantly make the daily freebies system more efficient. Is this also used in something like rarity of item spawns/drops?
|
Quote:
|
All times are GMT +2. The time now is 07:54 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.