Esempio n. 1
0
        static void Gus_OnGuess(Object sender, GusEventArgs e)
        {
            Console.WriteLine("Elapsed: {0}.", e.Elapsed);
            Console.WriteLine("I predict {0} ({1}).", e.Prediction, e.Hypothesis);
            Console.WriteLine(new GusLDescriber(e.Hypothesis).GetDescription());
            var y = Choose("Am I correct?", new List <char> {
                'Y', 'N'
            });

            if (y == 'Y')
            {
                e.IsCorrect = true;
            }
            else
            {
                Console.WriteLine("Ok, let me try again.");
            }
        }
Esempio n. 2
0
        public void GuessSequence(List <int> sequence)
        {
            var sw = new Stopwatch();

            sw.Start();

            foreach (var hypothesis in Hypothesise())
            {
                int prediction;
                if (TestHypothesis(sequence, hypothesis, false, out prediction))
                {
                    sw.Stop();

                    var gusEventArgs = new GusEventArgs
                    {
                        Elapsed    = sw.Elapsed,
                        Prediction = prediction,
                        Hypothesis = hypothesis
                    };
                    var guess = OnGuess;
                    if (guess != null)
                    {
                        guess(this, gusEventArgs);
                    }
                    // Stop if correct
                    if (gusEventArgs.IsCorrect)
                    {
                        // Remember this rule
                        Remember(hypothesis);
                        break;
                    }
                    sw.Reset();
                    sw.Restart();
                }
            }
        }