Exemple #1
0
        private static string[] solve(i_bot bot, string answer, bool verbose)
        {
            List <string> guesses = new List <string>();

            c_guess guess = null;

            while (!bot.solved())
            {
                if (verbose)
                {
                    bot.print_suggestions();
                }

                guess = null;

                if (answer != null)
                {
                    guess = new c_guess(bot.get_best_guess(), answer);
                }

                while (guess == null)
                {
                    Console.Write("Input guess and result: ");

                    try
                    {
                        string guess_input = Console.ReadLine();
                        guess = new c_guess(guess_input);
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("    Error - unable to parse input");
                        Console.ResetColor();
                    }
                }

                guesses.Add(guess.to_string());

                guess.write_line(verbose);

                bot.apply(guess);
            }

            if (!guess.is_solution())
            {
                guesses.Add(bot.get_solution());
            }

            if (verbose)
            {
                bot.print_solution();
            }
            else
            {
                Console.WriteLine();
            }

            return(guesses.ToArray());
        }
Exemple #2
0
        public void apply(c_guess guess)
        {
            m_answers.apply(guess);

            m_hints.score_hints(m_answers);
        }
Exemple #3
0
 public void apply(c_guess guess)
 {
     m_possible_answers = m_possible_answers.apply(guess);
 }