This is a mostly useless utility script for DreamBot to visualize the distribution of various random number generators. Inspired by this forum thread. (Gaussian algorithms taken from that thread, with some cleaning and a couple bug fixes)
X-Axis of the graph is each potentially generated point. Y-Axis is the relative probability of being generated. Points higher on the y-axis have a higher probability of being generated than other points.
Green points are points that tie for the highest probability. Orange points are generated points that tie for the lowest probability. Red points are points that haven't been generated at all.
Yellow line is an average of the surrounding generated points. Blue line is a bezier curve using the averages of the generated points as control points.
Standard (random.nextInt())
Low (random.nextGaussian() with a low bias)
Mid (random.nextGaussian() with a mid bias)
High (random.nextGaussian() with a high bias)
Park and Miller
Note that this algorithm is very slow, especially when you clamp it to very small values.
W (Mixture of Low, Mid, and High)
private int generateW()
{
switch (Random.nextInt(3))
{
case 0:
return Random.low(points.length / 2);
case 1:
return Random.mid(points.length / 3, points.length / 3 * 2);
default:
return Random.high(points.length / 2, points.length);
}
}
Humps (Two Mids side by side)
private int generateHumps()
{
if (Random.nextInt(2) == 0)
return Random.mid(points.length / 2);
return Random.mid(points.length / 2, points.length);
}
Valley (Mixture of Low, Mid-left, Mid-right, and High)
private int generateValley()
{
switch (Random.nextInt(4))
{
case 0:
return Random.low(points.length / 3);
case 1:
return Random.mid(points.length / 5 * 2);
case 2:
return Random.mid(points.length / 5 * 3, points.length);
default:
return Random.high(points.length / 3 * 2, points.length);
}
}