Fixed issue with Draw

This commit is contained in:
Chomp
2025-01-23 20:48:33 +00:00
parent 0938807640
commit c0cbcee4be
@@ -172,7 +172,7 @@ public class ProbabilityObjectArray<T, K, V> : List<T> where T : ProbabilityObje
for (var i = 0; i < count; i++) for (var i = 0; i < count; i++)
{ {
var rand = Random.Shared.NextDouble(); var rand = Random.Shared.NextDouble();
var randomIndex = (int)probCumsum.First((x) => x > rand); var randomIndex = (int)probCumsum.FindIndex((x) => x > rand);
// We cannot put Math.random() directly in the findIndex because then it draws anew for each of its iteration // We cannot put Math.random() directly in the findIndex because then it draws anew for each of its iteration
if (replacement || lockList.Contains(totals.keyArray[randomIndex])) if (replacement || lockList.Contains(totals.keyArray[randomIndex]))
{ {