Factoids: fix off-by-one in weighted selection

This commit is contained in:
Pragmatic Software 2020-06-17 11:36:42 -07:00
parent f2ab97e681
commit 6ea523f608
1 changed files with 1 additions and 1 deletions

View File

@ -600,7 +600,7 @@ sub select_weighted_item_from_list {
my $n = int rand $weight_sum;
for my $weight (@weights) {
if ($n <= $weight->[0]) {
if ($n < $weight->[0]) {
return $list->[$weight->[1]];
}
$n -= $weight->[0];