How can I generate a random number that is the same depending on the x
, y
, and seed
values? So if you kept choosing the exact same values for x
, y
, and seed
, it would always return the same float
from 0.0
to 1.0
. Something like:
//Returns value from 0.0 to 1.0
public static float random(int seed, int x, int y) {
...
return rand;
}
EDIT: I think I have found a method that would do the job (Sorry if I was asking the wrong question):
public static float random(int x, int y) {
int n = x + y * 57;
n = (n << 13) ^ n;
return Math.abs((1.0f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7FFFFFFF) / 1073741824.0f));
}