Fixed bug in rng::roulette_wheel: use of float had too little precision in change/fortune var
This commit is contained in:
parent
a715dda207
commit
4bdccb3dae
1 changed files with 4 additions and 5 deletions
|
|
@ -224,13 +224,12 @@ public :
|
||||||
total += vec[i];
|
total += vec[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
float change = uniform() * total;
|
double fortune = uniform() * total;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (change > 0)
|
while (fortune > 0)
|
||||||
{
|
{
|
||||||
change -= vec[i++];
|
fortune -= vec[i++];
|
||||||
}
|
}
|
||||||
|
|
||||||
return --i;
|
return --i;
|
||||||
|
|
|
||||||
Reference in a new issue