public List <int> RunBatch(string type) { Counter c; List <int> tries = new List <int>(); for (int i = 1; i < 101; i++) { GuessingGame gg = new GuessingGame(i, 1, 100); if (type == "random") { c = new Counter(new RandomGuesser()); } else if (type == "elim") { c = new Counter(new GuesserElim(gg.Min, gg.Max)); } else if (type == "merge") { c = new Counter(new BinaryGuesser(gg.Min, gg.Max, gg)); } else { c = new Counter(new RandomGuesser()); } int attempt = c.CountTries(gg); tries.Add(attempt); } PrintListInfo(tries, type); return(tries); }
public int CountTries(GuessingGame gg) { GuessQuality output = GuessQuality.Start; int tries = 0; while (output != GuessQuality.Match) { tries++; int guess = g.GenerateGuess(); output = gg.MakeGuess(guess); g.LastGuess = output; } return(tries); }
public void PlayGame() { GuessQuality output = GuessQuality.TooLow; while (output != GuessQuality.Match) { GuessingGame gg = new GuessingGame(); Console.WriteLine("Please input a number between 1 and 100:"); int input = int.Parse(Console.ReadLine()); output = gg.MakeGuess(input); Console.WriteLine(output); if (output == GuessQuality.Match) { Console.WriteLine("You win!!!"); } } }
public BinaryGuesser(int min, int max, GuessingGame gg) { this.min = min; this.max = max; this.gg = gg; }