corrected bad index error when uniform()=0 in roulette_wheel. The error was: if fortune=0, we first have "int i=0", then "return --i" .
This commit is contained in:
parent
28abc86db7
commit
4834adbe5f
1 changed files with 1 additions and 1 deletions
|
|
@ -263,7 +263,7 @@ public :
|
|||
}
|
||||
double fortune = uniform() * total;
|
||||
int i = 0;
|
||||
while (fortune > 0)
|
||||
while (fortune >= 0)
|
||||
{
|
||||
fortune -= vec[i++];
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue