示例#1
0
        private void CalculatePercentagesBasedInBestRating(Race myrace)
        {
            List<double> bestRatingList = new List<double>();

            foreach (BrisHorse brisHorse in _horse)
            {
                if (!IsHorseScratched(brisHorse, myrace))
                {
                    bestRatingList.Add(brisHorse.BestRating);
                }
            }

            FiguresToProbabilities fp = new FiguresToProbabilities();
            List<double> percentages = fp.Calculate(bestRatingList, Utilities.BEST_RATING_CONSTANT);

            Debug.Assert(percentages.Count == bestRatingList.Count);

            int i = 0;
            foreach (BrisHorse brisHorse in _horse)
            {
                if (!IsHorseScratched(brisHorse, myrace))
                {
                    brisHorse.WinningPercentBasedInBestRating = percentages[i++];
                }
            }
        }
示例#2
0
        private void CalculatePercentagesBasedInBrisPrimePower(Race myrace)
        {
            List<double> primePowerList = new List<double>();

            foreach (BrisHorse brisHorse in _horse)
            {
                if (!IsHorseScratched(brisHorse, myrace))
                {
                    primePowerList.Add((double)brisHorse.PrimePowerRating);
                }
            }

            FiguresToProbabilities fp = new FiguresToProbabilities();
            List<double> percentages = fp.Calculate(primePowerList, Utilities.PRIME_POWER_CONSTANT);

            Debug.Assert(percentages.Count == primePowerList.Count);

            int i = 0;
            foreach (BrisHorse brisHorse in _horse)
            {
                if (!IsHorseScratched(brisHorse, myrace))
                {
                    brisHorse.WinningPercentBasedInPrimePower = percentages[i++];
                }
            }
        }
        private void ProcessRace(Race race, int constant, BrisRace brisRace,string filename)
        {
            UpdateObserver(string.Format("Processing race {0} with constant = {1} {2}", race.RaceNumber,constant,filename));
            List<double> figure = new List<double>();
            Dictionary<string, int> horseIndex = new Dictionary<string, int>();

            int index = 0;
            foreach (Horse horse in race.Horses)
            {
                if (!horse.Scratched)
                {
                    if (horse.ProgramNumber.Trim().Length == 0)
                    {
                        continue;
                    }
                    BrisHorse brisHorse = brisRace.GetHorseFromItsNumber(horse.ProgramNumber);

                    if (null != GetValue)
                    {
                        figure.Add(GetValue(brisHorse));
                        horseIndex.Add(brisHorse.ProgramNumber.Trim(), index);
                        ++index;
                    }
                }
            }

            FiguresToProbabilities fp = new FiguresToProbabilities();

            figure = fp.Calculate(figure, constant);

            string programNumber = GetWinnerForRace(race.Parent.BrisAbrvTrackCode, race.Parent.Date, race.RaceNumber).Trim();

            if (horseIndex.ContainsKey(programNumber))
            {
                int i = horseIndex[programNumber];

                double winnersFigure = figure[i];

                if (!_winnerPercentage.ContainsKey(constant))
                {
                    _winnerPercentage.Add(constant, new List<double>());
                }

                _winnerPercentage[constant].Add(winnersFigure);
            }
        }