package kaaass.perlin2d.random;

public class RandomGenerator {
	private static int[] seedWH = { 13, 97, 223 };
	private static int[] seedRSA = { 77, 32771 };

	/*
	 * x input
	 */

	/**
	 * This is a method of Wichman-Hill random number generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomWH(int x) {
		int[] seed = new int[3];
		for (int i = 0; i <= Math.abs(x); i++) {
			seed[0] = (171 * seedWH[0]) % 30269;
			seed[1] = (172 * seedWH[1]) % 30307;
			seed[2] = (170 * seedWH[2]) % 30323;
		}
		return (x / Math.abs(x))
				* (seed[0] / 30269.0F + seed[1] / 30307.0F + seed[2] / 30323.0F)
				% 1.0F;
	}

	/**
	 * This is a method of RSA.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomRSA(int x) {
		return (float) (x * Math.exp(seedRSA[0]) % seedRSA[1] / seedRSA[1]);
	}

	/**
	 * This is a method of basic random generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomBasic(int x) {
		x = (x << 13) ^ x;
		return (float) (1.0 - Float.floatToIntBits((x
				* (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
	}

	/**
	 * This is a method of Java random number generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomJava(int x) {
		return (float) (new java.util.Random(x).nextDouble() * 2 - 1);
	}

	/*
	 * x-y input
	 */

	/**
	 * This is a method of Wichman-Hill random number generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @param y
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomWH(int x, int y) {
		x += y * 57;
		int[] seed = new int[3];
		for (int i = 0; i <= Math.abs(x); i++) {
			seed[0] = (171 * seedWH[0]) % 30269;
			seed[1] = (172 * seedWH[1]) % 30307;
			seed[2] = (170 * seedWH[2]) % 30323;
		}
		return (x / Math.abs(x))
				* (seed[0] / 30269.0F + seed[1] / 30307.0F + seed[2] / 30323.0F)
				% 1.0F;
	}

	/**
	 * This is a method of RSA.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @param y
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomRSA(int x, int y) {
		x += y * 57;
		return (float) (x * Math.exp(seedRSA[0]) % seedRSA[1] / seedRSA[1]);
	}

	/**
	 * This is a method of basic random generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @param y
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomBasic(int x, int y) {
		x += y * 57;
		x = (x << 13) ^ x;
		return (float) (1.0 - Float.floatToIntBits((x
				* (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
	}

	/**
	 * This is a method of Java random number generator.
	 * 
	 * @param x
	 *            A seed for generator.
	 * @param y
	 *            A seed for generator.
	 * @return A float random value between [0.0,1.0)
	 */
	public static float randomJava(int x, int y) {
		x += y * 57;
		return (float) (new java.util.Random(x).nextDouble() * 2 - 1);
	}
}

@@ -1897,321 +1897,46 @@
 %7B%0A%09%09
-x += y * 57;%0A%09%09int%5B%5D seed = new int%5B3%5D;%0A%09%09for (int i = 0; i %3C= Math.abs(x); i++) %7B%0A%09%09%09seed%5B0%5D = (171 * seedWH%5B0%5D) %25 30269;%0A%09%09%09seed%5B1%5D = (172 * seedWH%5B1%5D) %25 30307;%0A%09%09%09seed%5B2%5D = (170 * seedWH%5B2%5D) %25 30323;%0A%09%09%7D%0A%09%09return (x / Math.abs(x))%0A%09%09%09%09* (seed%5B0%5D / 30269.0F + seed%5B1%5D / 30307.0F + seed%5B2%5D / 30323.0F)%0A%09%09%09%09%25 1.0F
+return (randomWH(x) + randomWH(y)) / 2
 ;%0A%09%7D
@@ -2185,90 +2185,48 @@
 %7B%0A%09%09
-x += y * 57;%0A%09%09return (float) (x * Math.exp(seedRSA%5B0%5D) %25 seedRSA%5B1%5D / seedRSA%5B1%5D)
+return (randomRSA(x) + randomRSA(y)) / 2
 ;%0A%09%7D
@@ -2928,84 +2928,50 @@
 %7B%0A%09%09
-x += y * 57;%0A%09%09return (float) (new java.util.Random(x).nextDouble() *
+return (randomJava(x) + randomJava(y)) /
  2
- - 1)
 ;%0A%09%7D

Fix typos and x-y inputs' generator method.