public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { Console.WriteLine($"You pulled card {m.Name} ({m.Description})"); var c = 1; Console.WriteLine("Choose your attribute to play..."); foreach (var stat in m.Stats) { Console.WriteLine($"{c} - {stat.Key} \t\t\t {stat.Value}"); c++; } var choice = Console.ReadKey().KeyChar.ToString(); if (int.TryParse(choice, out int i) && (i >= 1 && i <= 5)) { return(m.Stats.ToList()[i - 1].Key, m.Stats.ToList()[i - 1].Value); } else { Console.WriteLine("Invalid Choice..."); DecideAttributeToPlay(m); } return(BiscuitAttribute.Sweetness, 0); }
public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { //plays the lowest attribute Console.WriteLine("Thinking...."); Thread.Sleep(3000); var attr = m.Stats.Aggregate((l, r) => l.Value < r.Value ? l : r).Key; return(attr, m.Stats[attr]); }
public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { //we just play the highest attribute we have - simple //pretend to think Console.WriteLine("Thinking...."); Thread.Sleep(3000); var attr = m.Stats.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; return(attr, m.Stats[attr]); }
public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { //picks a random attribute Console.WriteLine("Thinking...."); Random ran = new Random(); int rInt = ran.Next(1, 5); //had to put the keys in a list to pick randomly List <BiscuitAttribute> BList = new List <BiscuitAttribute>(m.Stats.Keys); var attr = BList[rInt]; return(attr, m.Stats[attr]); }
public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { //this guy is insane, he'll just pick the lowest attribute possible //Gets distracted Console.Write("Distracted...."); Thread.Sleep(5000); Console.WriteLine("Take THIS!"); //Never worked with aggregates before, but I will modify it to pick the lowest instead of highest value var attr = m.Stats.Aggregate((l, r) => l.Value < r.Value ? l : r).Key; return(attr, m.Stats[attr]); }
public (BiscuitAttribute Attr, int Score) DecideAttributeToPlay(IBiscuitCard m) { //this AI is crazy, and doesn't care what attribute it plays, picks any attribute randomly Console.WriteLine("Who cares..."); Thread.Sleep(500); //create a random number generator var rand = new Random(); //gets a copy of the attributes keys in a list so we can select one at random var attributes = m.Stats.Keys.ToList(); //Selects one of these attributes using a random index between 0 and the number of attributes on a list copy of the attribute dictionary keys var attr = attributes[rand.Next(0, attributes.Count)]; //returns the attribute and it's score return(attr, m.Stats[attr]); }