Exemplo n.º 1
0
	private void TestSeed()
	{
		int seed = 12345678;
		string phrase = "seed test";
		MTRandom mrand_int = new MTRandom(seed);
		MTRandom mrand_string = new MTRandom(phrase);
		DebugStreamer.AddMessage("Runnig seed test:");
		string test_result;
		float value = mrand_int.value();
		test_result = value.ToString("0.0000000") == "0.2458042" ? "OK" : "NOT OK";
		DebugStreamer.AddMessage("Using seed NUMBER: " + seed + " EXPECTING: 0.2458042 RESULT: " + test_result);
		value = mrand_string.value();
		test_result = value.ToString("0.0000000") == "0.1944317" ? "OK" : "NOT OK";
		DebugStreamer.AddMessage("Using seed STRING: \"" + phrase + "\" EXPECTING: 0.1944317 RESULT: " + test_result);
	}
Exemplo n.º 2
0
	private void RandomValues()
	{
		CleanUp();
		DebugStreamer.AddMessage("Returns a pseudo-random number between 0.0 [inclusive] and 1.0 [inclusive]");
		DebugStreamer.AddMessage("MTRandom mrand = new MTRandom(seed)");
		mrand = new MTRandom(user_seed);
		DebugStreamer.AddMessage("mrand.value()");
		for (int i = 0; i < max_objects; i++)
		{
			float x = mrand.value();
			float x_position = MTRandom.ScaleFloatToRange(x, -2.0f, 2.0f, 0.0f, 1.0f);
			GameObject sphere = MakeObject(new Vector3(x_position,x_position,0.0f));
			sphere.name = x.ToString();
		}
	}