i went into trying to draw a simple star map. For this i first calculate the x and y position for the stars. X and Y are within the range of width and height of the window.
This is my random number generating function:
template<typename T>
T getRandomNumberBetween(const T& Min, const T& Max)
{
std::random_device rd;
std::default_random_engine generator{rd()};
std::uniform_int_distribution<T> dist{Min, Max};
return dist(generator);
}
And i use it like this:
auto calculate_x_position = std::bind(inc::getRandomNumberBetween<sf::Uint32>, 0, W-1);
auto calculate_y_position = std::bind(inc::getRandomNumberBetween<sf::Uint32>, 0, H-1);
x = calculate_x_position(); //...
But as i draw my map over and over again it seems to me that there is a pivot to where most stars tend to be. E.g. the majority of stars are in the upper half of my window.
Examples:
Am i using it wrong or having a wrong expectation here?... Because here it says:
This distribution produces random integers in a range [a,b] where each possible value has an equal likelihood of being produced.
Kind Regards
Aucun commentaire:
Enregistrer un commentaire