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,15 +224,14 @@ public :
|
|||
total += vec[i];
|
||||
}
|
||||
|
||||
float change = uniform() * total;
|
||||
|
||||
double fortune = uniform() * total;
|
||||
int i = 0;
|
||||
|
||||
while (change > 0)
|
||||
while (fortune > 0)
|
||||
{
|
||||
change -= vec[i++];
|
||||
fortune -= vec[i++];
|
||||
}
|
||||
|
||||
|
||||
return --i;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue