I got this weird bug that is keeping me awake right now, and I can't seem to get it fixed,
sometimes it displays all of them filled in, but sometimes it leaves gaps like you can see..
Here's the code:
static string[] cards = new string[52]; //all indexes already assigned
static string[] AI1cards = new string[13]; // 13 cards for AI 1
static Random rand = new Random();
static List uniqueNumber = new List();
for (int i = 0; i < AI1cards.Length; i++)
{
int number = rand.Next(0, 51);
while (uniqueNumber.Contains(number))
{
number = rand.Next(0, 51);
}
uniqueNumber.Add(number);
AI1cards[i] = cards[number];
}
//Print on console
for (int i = 0; i < AI1cards.Length; i++)
{
Console.WriteLine("AI1 Card " +i+ ": " + AI1cards[i]);
}
Console prints: (always random but leaves gaps sometimes for some reason)
AI1 Card 0: Heart 5
AI1 Card 1:
AI1 Card 2: Diamonds 4
AI1 Card 3: Heart J
AI1 Card 4:
AI1 Card 5: Diamonds J
AI1 Card 6: Heart 8
AI1 Card 7: Clubs 5
AI1 Card 8: Diamonds 6
AI1 Card 9: Clubs 9
AI1 Card 10: Heart 2
AI1 Card 11: Clubs 4
AI1 Card 12: Heart 10
↧