-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Helton Reis edited this page Oct 8, 2019
·
2 revisions
The purpose of this wiki is to provide documentation to the library and some examples of usage.
Obs.: The source code can provide the majority of the documentation already and will be updated faster, the difference between the source code and the wiki, is that in here you will find examples of usage
The code will select 10 of the available choices based on their weights and display one by line on the console
using WeightedRandomSelectionLib;
class Program {
static void Main (string[] args)
{
WeightedRandomSelector<string> selector = new WeightedRandomSelector<string>();
selector.Add("Choice 1", 0.8);
selector.Add("Choice 2", 15.0);
selector.Add("Choice 3", 62.21);
selector.Add("Choice 4", 32.5);
selector.Add("Choice 5", 70.0);
foreach (string i in selector.SelectMultiple (10))
{
Console.WriteLine(i);
}
}
}