I need to know how to implement a greedy algorithm in a card game using C#. The game is a turn based game. When the AI should issue some cards, it must be based on the latest state of other cards that already are on the table. Does anyone have a solution for this, or maybe a reference for me to get started? Thanks in advance!
For now I only finished the code to shuffle the cards:
List<int> cards = new List<int>();
for (int j = 1; j <= 2; j++)
{
for (int i = 1; i <= 54; i++)
{
cards.Add(i);
}
}
List<int> ShuffledCards = new List<int>();
Random random = new Random();
int iterations = cards.Count;
int index = 0;
for (int j = 1; j <= 2; j++)
{
for (int i = 0; i < iterations; i++)
{
index = random.Next(0, iterations - i);
ShuffledCards.Add(cards[index]);
cards.RemoveAt(index);
}
iterations = cards.Count;
index = 0;
}
ShuffledCards.Reverse(0, ShuffledCards.Count);
ShuffledCards.RemoveRange(0, 8);
ShuffledCards.Reverse(0, ShuffledCards.Count);
This book is like a bible about AI. You can start with reading first 3 parts of this book.