private int PickByWeight(List<int> items, LongRandom rand)
{
int total = TotalWeights(items);
int randomNumber = rand.Next(0, total);
int selectedIndex = 0;
int count = items.Count;
for (int i = 0; i < count; i++)
{
if (randomNumber < this.Weights[items[i]] + this.DistWeights[items[i]])
{
selectedIndex = i;
break;
}
randomNumber -= this.Weights[items[i]] + this.DistWeights[items[i]];
}
return selectedIndex;
}