You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
236 B
11 lines
236 B
#include <common/pseudorand.h>
|
|
#include <common/random_select.h>
|
|
|
|
bool random_select(double weight, double *tot_weight)
|
|
{
|
|
*tot_weight += weight;
|
|
if (weight == 0)
|
|
return false;
|
|
|
|
return pseudorand_double() <= weight / *tot_weight;
|
|
}
|
|
|