Exemplo n.º 1
0
        private static void AllDraws(DrawHistory draws, List<CalculatorHost> calculators, Draw lastDraw)
        {
            int totalDraws = draws.Count;

            Console.WriteLine("Draws");
            Console.WriteLine("All " + totalDraws);

            int validDraws = 0;
            int invalidDraws = 0;

            var list = draws.GetRange(0, draws.Count - 1);

            foreach (Draw draw in list)
            {
                bool isValid = true;

                foreach (CalculatorHost calculator in calculators)
                {
                    if (!calculator.Validate(lastDraw, draw))
                    {
                        isValid = false;
                        break;
                    }
                }

                if (isValid)
                    validDraws++;
                else
                    invalidDraws++;
            }

            Console.WriteLine("Valid " + validDraws + " - " + (((double)validDraws / (double)totalDraws) * 100));
            Console.WriteLine("Invaild " + invalidDraws + " - " + (((double)invalidDraws / (double)totalDraws) * 100));
        }
Exemplo n.º 2
0
        public bool IsEqual(Draw draw)
        {
            bool flag = (draw.Ball.Count == this.Ball.Count);

            foreach (int i in this.Ball)
            {
                flag = flag && draw.Ball.Contains(i);
            }

            return flag;
        }
Exemplo n.º 3
0
        private static void AllCombinations(List<CalculatorHost> calculators, Draw lastDraw)
        {
            List<List<int>> allCombinations = GetAllCombinations();

            int totalCombinations = allCombinations.Count;

            Console.WriteLine("Combinations");
            Console.WriteLine("All " + totalCombinations);

            int validCombinations = 0;
            int invalidCombinations = 0;

            foreach (List<int> combination in allCombinations)
            {
                Draw draw = new Draw(combination);

                bool isValid = true;

                foreach (CalculatorHost calculator in calculators)
                {
                    if (!calculator.Validate(lastDraw, draw))
                    {
                        isValid = false;
                        break;
                    }
                }

                if (isValid)
                    validCombinations++;
                else
                    invalidCombinations++;
            }

            Console.WriteLine("Valid " + validCombinations + " - " + (((double)validCombinations / (double)totalCombinations) * 100));
            Console.WriteLine("Invaild " + invalidCombinations + " - " + (((double)invalidCombinations / (double)totalCombinations) * 100));
        }
Exemplo n.º 4
0
        public int Matches(Draw draw)
        {
            int m = 0;
            foreach (int i in this.Ball)
            {
                if (draw.Ball.Contains(i))
                    m++;
            }

            return m;
        }
Exemplo n.º 5
0
 public bool Validate(Draw latest, Draw predicted)
 {
     return _calculator.Validate(latest, predicted);
 }
Exemplo n.º 6
0
        private static void ValidateLastDrawAgainstPrevious(List<CalculatorHost> calculators, Draw lastDraw, Draw prevToLastDraw)
        {
            StringBuilder sb = new StringBuilder();

            foreach (CalculatorHost calculator in calculators)
            {
                if (!calculator.Validate(prevToLastDraw, lastDraw))
                {
                    if (sb.Length > 0)
                        sb.Append("; ");

                    sb.Append(calculator.Name);
                }
            }

            if (sb.Length > 0)
            {
                Console.WriteLine("Prev to last: " + prevToLastDraw.ToString() + "");
                Console.WriteLine("Last draw failed: ");
                sb.Insert(0, "\t");
                Console.WriteLine(sb.ToString());
            }
        }
Exemplo n.º 7
0
        public bool Validate(Draw latest, Draw predicted)
        {
            int m = predicted.Matches(latest);

            return (m == tm1 || m == tm2);
        }
Exemplo n.º 8
0
        public void Populate(Draw draw)
        {
            totalDraws++;

            if (PrevWeeksDraw != null)
                counts[draw.Matches(PrevWeeksDraw)]++;

            PrevWeeksDraw = draw;
        }