tov / ge211

A relatively simple C++ student game engine
https://tov.github.io/ge211/
6 stars 3 forks source link

Doc for Random source wrong #1

Closed brghena closed 3 years ago

brghena commented 3 years ago

I think the constructor Random_source(result_type min, result_type max) constructs a random source that generates values between min and max exclusive.

Alternatively, the example code may be wrong, as it calls (1,7) to get a six-sided die.

https://tov.github.io/ge211/classge211_1_1_random__source.html#a3c7be16a8b2f45f8980949d5eb5476d1

tov commented 3 years ago

Hmmm. This is probably because I changed it, but I don’t know which it’s doing now…

tov commented 3 years ago

Experiment confirms that the range is inclusive. This prints both 1s and 2s:

    ge211::Random_source<int> src(1, 2);
    for (int i = 0; i < 10; ++i) {
        std::cout << src() << "\n";
    }

I’ll fix the docs. Thanks!