The Random Run - ctouzel/randomrun GitHub Wiki
The goal of the random run application is to make many options run to get a random winner
DESIGN...
- convert old code into algorithmn written here
NEW ALGORYTHMN..
- CREATE list of last_places indexes
- CREATE randomizer object
- SET winner as -1
- SET race_won as FALSE
- PREPARE array of albums name
- PREPARE array of albums race progression
- ASK for names of albums
-
-
- PUT names in names array
-
- LAUNCH race
OLD CODE ALGORYTHMN...
List<int> lastPlaces = new List<int>();
Random rnd = new Random();
int winner = -1;
bool won = false;
string[] albums = new string[5];
int[] prog = new int[5];
Console.WriteLine();
Console.Write("1: ");
albums[0] = Console.ReadLine();
Console.Write("2: ");
albums[1] = Console.ReadLine();
Console.Write("3: ");
albums[2] = Console.ReadLine();
Console.Write("4: ");
albums[3] = Console.ReadLine();
Console.Write("5: ");
albums[4] = Console.ReadLine();
int neee = -1;
Console.Clear();
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < prog[i]; j++)
{
Console.Write(" ");
}
Console.WriteLine(i + 1);
}
Thread.Sleep(2000);
while(won == false)
{
Console.Clear();
neee = rnd.Next(5);
prog[neee]++;
// LAST PLACES
lastPlaces.Clear();
for (int i = 0; i < 5; i++)
{
bool last = true;
for (int k = 0; k < 5; k++)
{
if (k!=i)
{
if (prog[i] > prog[k])
{
last = false;
}
}
}
if (last)
{
lastPlaces.Add(i);
}
}
for (int i=0; i<5; i++)
{
for (int j=0; j<prog[i]; j++)
{
Console.Write(" ");
}
Console.WriteLine(i+1);
}
Thread.Sleep(50);
if (prog[neee]>78)
{
won = true;
winner = neee;
}
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("THE WINNER IS " + albums[winner]);
Console.WriteLine();
foreach(int num in lastPlaces)
{
Console.WriteLine(albums[num] + " is eliminated.");
}
Console.ReadLine();
IDEAS...
- ask number of concurrents
- ask is there elimination
- command line look? graphical look?