コード例 #1
0
        private void DisplayStatistics(StrategyBase strategy)
        {
            // then display the final results
            Dispatcher.BeginInvoke(new Action(() =>
            {
                stopwatch.Stop();

                // test it and display scores
                var tester = new StrategyTester(strategy, ProgramConfiguration.TestSettings);

                double average, stdDev, coeffVariation;
                tester.GetStatistics(out average, out stdDev, out coeffVariation);

                string scoreResults =
                    "\nAverage score: " + average.ToString("0") +
                    "\nStandard Deviation: " + stdDev.ToString("0") +
                    "\nCoeff. of Variation: " + coeffVariation.ToString("0.0000");

                gaResultTB.Text = "Solution found in " + totalGenerations + " generations\nElapsed: " +
                                  stopwatch.Elapsed.Hours + "h " +
                                  stopwatch.Elapsed.Minutes + "m " +
                                  stopwatch.Elapsed.Seconds + "s " +
                                  "\n\nTest Results:" + scoreResults;
            }),
                                   DispatcherPriority.Background);
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        // each candidate gets evaluated here
        //-------------------------------------------------------------------------
        private float EvaluateCandidate(Strategy candidate)
        {
            // test the strategy and return the total money lost/made
            var strategyTester = new StrategyTester(candidate, ProgramConfiguration.TestSettings);

            strategyTester.StackTheDeck = ProgramConfiguration.TestSettings.StackTheDeck;

            return(strategyTester.GetStrategyScore(ProgramConfiguration.TestSettings.NumHandsToPlay));
        }
コード例 #3
0
        private void TestStrategy(IStrategy strategy)
        {
            OutputTextBlock.Text = "Testing...";

            Task.Run(() =>
            {
                double avg, stdDev, coeffVariation;
                StrategyTester.GetStatistics(strategy, out avg, out stdDev, out coeffVariation);

                Dispatcher.Invoke(() =>
                {
                    OutputTextBlock.Text = $"Test results:\nAverage score: {avg.ToString("0")}\nStandard deviation: {stdDev.ToString("0")}\nCoefficient of variation: {coeffVariation.ToString("0.0000")}";
                }, DispatcherPriority.Background);
            });
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var allowedPrefixes = args.Length > 0 ? args : new[] { "FA", "FR", "FD" };
            var strategies      = AppDomain.CurrentDomain.GetAssemblies()
                                  .SelectMany(assembly => assembly.GetTypes())
                                  .Where(
                type =>
                type.IsClass &&
                !type.IsAbstract &&
                typeof(IStrategy).IsAssignableFrom(type) &&
                type.GetCustomAttributes(typeof(BrokenStrategy), true).Length == 0)
                                  .Where(type => type == typeof(BfsStrategy))
                                  .Select(CreateStrategy)
                                  .Where(strategy => strategy != null);

            StrategyTester tester = new StrategyTester(allowedPrefixes);

            tester.Test("Data/Problems", "Data/BestTraces", "Data/DefaultTraces", strategies);
        }
コード例 #5
0
        public double Evaluate(IChromosome chromosome)
        {
            var strategy = (BlackjackChromosome)chromosome;

            return(StrategyTester.Test(strategy));
        }