I'm trying to make a random item picker, that randomly picks items 3 by 3. The probabilities are not equal.
namespace Picker
{
class Program
{
static bool doContinue = true;
static double[] numbers = { 4, 12, 28, 60, 124, 252, 508, 1020, 2044, 4092, 4120, 4176, 4288, 4512, 4960, 5856, 7648, 11232, 18400, 32736 };
static string Pick()
{
double rnd = new Random().NextDouble() * 32736;
byte type = 0;
for (byte i = 0; i < 20; i++) {
if (rnd <= numbers[i])
{
type = i;
break;
}
}
string reverString = "";
if (type < 10)
{
reverString = " Reverse";
}
return "T" + (10 - (type % 10)).ToString() + reverString;
}
static void Main(string[] args)
{
while (doContinue)
{
Console.WriteLine(Pick());
Thread.Sleep(2);
Console.WriteLine(Pick());
Thread.Sleep(2);
Console.WriteLine(Pick());
Thread.Sleep(2);
Console.ReadLine();
}
}
}
}
The picks done 3 by 3 are always the same thing 3 times, and then it changes.
PS : I know, the doContinue thing is not implemented.