X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frandom_generator.cpp;h=f1491736e04700f446e48728440abcdbfdad0ea4;hb=755ac9ae45065248ddf1343a82671f871b447577;hp=1cfeecf29fa38a253acd5f95ffdded855d8b9d0b;hpb=7c579d3ef0a6667c18b53dad84c63c05d2760a84;p=supertux.git diff --git a/src/random_generator.cpp b/src/random_generator.cpp index 1cfeecf29..f1491736e 100644 --- a/src/random_generator.cpp +++ b/src/random_generator.cpp @@ -37,7 +37,9 @@ #include -#include +#include +#include +#include #include "random_generator.hpp" RandomGenerator systemRandom; // global random number generator @@ -66,7 +68,7 @@ int RandomGenerator::srand(int x) { } int RandomGenerator::rand() { - int rv; // a posative int + int rv; // a positive int while ((rv = RandomGenerator::random()) <= 0) // neg or zero causes probs ; if (debug > 0) @@ -93,8 +95,8 @@ int RandomGenerator::rand(int u, int v) { double RandomGenerator::randf(double v) { float rv; do { - rv = ((double)RandomGenerator::random())/RandomGenerator::rand_max * v; - } while (rv >= v); // rounding might cause rv==v + rv = ((double)RandomGenerator::random())/RandomGenerator::rand_max * v; + } while (rv >= v); // rounding might cause rv==v if (debug > 0) printf("==== rand(): %f =====\n", rv); @@ -146,7 +148,7 @@ double RandomGenerator::randf(double u, double v) { // then initialized to contain information for random number generation with // that much state information. Good sizes for the amount of state // information are 32, 64, 128, and 256 bytes. The state can be switched by -// calling the setstate() routine with the same array as was initiallized +// calling the setstate() routine with the same array as was initialized // with initstate(). By default, the package runs with 128 bytes of state // information and generates far better random numbers than a linear // congruential generator. If the amount of state information is less than @@ -301,7 +303,7 @@ void RandomGenerator::initialize() { // // Compute x = (7^5 * x) mod (2^31 - 1) -// wihout overflowing 31 bits: +// without overflowing 31 bits: // (2^31 - 1) = 127773 * (7^5) + 2836 // From "Random number generators: good ones are hard to find", // Park and Miller, Communications of the ACM, vol. 31, no. 10,