Esempio n. 1
0
        public void Run()
        {
            // Test: Roll dice several times, and run all evaluators for each roll
            for (int i = 0; i < 1000; i++)
            {
                // Roll dice
                _cup.Shake();

                // Pick up evaluations
                DiceEvaluation diceEval = new DiceEvaluation(_cup.DiceFaceValues);

                // Run each evaluator against the dice
                foreach (var eval in _diceEvaluators)
                {
                    string         evalDescription = eval.Key;
                    IDiceEvaluator iDiceEval       = eval.Value;
                    int            points          = iDiceEval.Evaluate(_cup.DiceCountByFaceValue);

                    diceEval.AddEvaluation(evalDescription, points);
                }

                // Add this evaluation to stats
                _evaluationStats.AddEvaluation(diceEval);
            }

            // Print total evaluations
            Console.WriteLine(_evaluationStats);
            // Console.WriteLine(_evaluationStats.FilterStats(new List<string>{ "Tower" }));
        }
        public DiceEvaluationStatistics FilterStats(List <string> positiveEvals)
        {
            DiceEvaluationStatistics filteredStats = new DiceEvaluationStatistics();

            foreach (var eval in _evaluations)
            {
                bool evalAdded = false;
                foreach (var evalName in positiveEvals)
                {
                    if (!evalAdded && eval.Evaluations.ContainsKey(evalName) && eval.Evaluations[evalName] > 0)
                    {
                        filteredStats.AddEvaluation(eval);
                        evalAdded = true;
                    }
                }
            }

            return(filteredStats);
        }