mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Factoids: fix off-by-one in weighted selection
This commit is contained in:
parent
f2ab97e681
commit
6ea523f608
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user