Random Number Generator Biased To Numbers in the Middle of Range, Java, libGDX -
i designing game in libgdx drops different sized rocks user dodge.
my question: how can create method takes in low , high int value, , returns random number. however, want random number biased toward middle of range (similar normal distribution).
i method this: public int randbiasint(int low, int high) { }
something sort of should work...
public int getbiasedint(int min, int max) { int rand = math.random() * max; while (rand < min) { rand = math.random(); } int mid = (max / 2) - (min / 2); int halfmid = mid / 2; if (rand > mid) { rand -= math.random() * halfmid; } else { rand += math.random() * halfmid; } return rand; }
not prettiest, know. should acceptable desire...