コード例 #1
0
 internal void RecalcProbability()
 {
     Probability = 1;
     foreach (GamePick pick in GameWinners)
     {
         Matchup mh = ConfidencePoolAnalyzer.Matchups.FirstOrDefault(x => String.IsNullOrEmpty(x.Winner) && x.Home.Equals(pick.TeamAbbrev));
         Matchup ma = ConfidencePoolAnalyzer.Matchups.FirstOrDefault(x => String.IsNullOrEmpty(x.Winner) && x.Away.Equals(pick.TeamAbbrev));
         if (mh != null)
         {
             Probability *= mh.HomeWinPct;
         }
         else if (ma != null)
         {
             Probability *= (1 - ma.HomeWinPct);
         }
     }
 }
コード例 #2
0
        internal void UpdateMatchup(Matchup m)
        {
            try {
                NflGame game = _scoreStrip.Games.First(x => x.Home.Equals(m.Home) && x.Away.Equals(m.Away));
                m.AwayScore  = game.AwayScore;
                m.HomeScore  = game.HomeScore;
                m.Quarter    = game.Quarter;
                m.TimeLeft   = game.TimeLeft;
                m.Possession = game.Possession;
                m.RedZone    = game.RedZone == 1;
            }
            catch { }

            try {
                double spread = _odds.Games.First(x => x.Participants.Any(y => y.Name.Equals(m.Home)))
                                .Periods.First(x => x.PeriodNumber == 0).Spread.SpreadHome;
                m.Spread = spread;
            }
            catch { }
        }
コード例 #3
0
 internal PlayerEntry(string name, int bits, params object[] picks) : this(name)
 {
     Bits = bits;
     if (picks != null)
     {
         for (int i = 0; i < picks.Length; i += 2)
         {
             GamePicks.Add(new GamePick((string)picks[i], (int)picks[i + 1]));
         }
     }
     else if (Bits >= 0)
     {
         int bitsLeft = ConfidencePoolAnalyzer.Matchups.Count();
         while (bitsLeft > 0)
         {
             Matchup m = ConfidencePoolAnalyzer.Matchups[bitsLeft - 1];
             GamePicks.Add((bits & 1) == 1 ? new GamePick(m.Home, 0) : new GamePick(m.Away, 0));
             bits >>= 1;
             bitsLeft--;
         }
     }
 }
コード例 #4
0
        internal WeekPossibility(int bits)
        {
            Bits         = bits;
            GameWinners  = new List <GamePick>();
            PlayerScores = new List <PlayerScore>();
            List <Matchup> matchupsLeft = ConfidencePoolAnalyzer.Matchups.Where(x => String.IsNullOrEmpty(x.Winner)).ToList();

            int bitsLeft = matchupsLeft.Count();

            while (bitsLeft > 0)
            {
                Matchup m = matchupsLeft[bitsLeft - 1];
                GameWinners.Add((bits & 1) == 1 ? new GamePick(m.Home, 0) : new GamePick(m.Away, 0));
                bits >>= 1;
                bitsLeft--;
            }

            foreach (Matchup m in ConfidencePoolAnalyzer.Matchups.Where(x => !String.IsNullOrEmpty(x.Winner)))
            {
                GameWinners.Add(new GamePick(m.Winner, 0));
            }

            RecalcProbability();
        }
コード例 #5
0
        internal void UpdateMatchup(Matchup m)
        {
            try {
                NflGame game = _scoreStrip.Games.First(x => x.Home.Equals(m.Home) && x.Away.Equals(m.Away));
                m.AwayScore = game.AwayScore;
                m.HomeScore = game.HomeScore;
                m.Quarter = game.Quarter;
                m.TimeLeft = game.TimeLeft;
                m.Possession = game.Possession;
                m.RedZone = game.RedZone == 1;
            }
            catch { }

            try {
                double spread = _odds.Games.First(x => x.Participants.Any(y => y.Name.Equals(m.Home)))
                    .Periods.First(x => x.PeriodNumber == 0).Spread.SpreadHome;
                m.Spread = spread;
            }
            catch { }
        }
コード例 #6
0
        internal void ValidateLists()
        {
            foreach (string name in _entryWinCheck.Where(name => !PlayerEntries.Any(x => x.Name.Equals(name))))
            {
                throw new Exception("entrywincheck name doesn't match a player entry: " + name);
            }

            List <string> matchupTeams = new List <string>();

            foreach (Matchup m in Matchups)
            {
                if (matchupTeams.Contains(m.Home))
                {
                    throw new Exception("duplicate matchup team: " + m.Home);
                }
                matchupTeams.Add(m.Home);
                if (matchupTeams.Contains(m.Away))
                {
                    throw new Exception("duplicate matchup team: " + m.Away);
                }
                matchupTeams.Add(m.Away);

                if (!String.IsNullOrEmpty(m.Winner) && !m.Winner.Equals(m.Home) && !m.Winner.Equals(m.Away) && !m.Winner.Equals("T"))
                {
                    throw new Exception("matchup winner not valid: " + m.Winner);
                }
            }

            List <string> entryNames  = new List <string>();
            int           numMatchups = Matchups.Count();

            foreach (PlayerEntry entry in PlayerEntries)
            {
                if (entryNames.Contains(entry.Name))
                {
                    throw new Exception("duplicate entry name: " + entry.Name);
                }
                entryNames.Add(entry.Name);

                //if (entry.GamePicks.Count() != numMatchups) throw new Exception(entry.Name + " has wrong number of picks: " + entry.GamePicks.Count());

                int pointsTotExpected = (int)((16.5 * numMatchups) - (Math.Pow(numMatchups, 2) / 2));
                //if (entry.GamePicks.Sum(x => x.Points) != pointsTotExpected) throw new Exception(entry.Name + " has invalid points total");

                List <string>  teamsPicked    = new List <string>();
                List <int>     pointsPicked   = new List <int>();
                List <Matchup> matchupsPicked = new List <Matchup>();
                foreach (GamePick pick in entry.GamePicks)
                {
                    if (teamsPicked.Contains(pick.TeamAbbrev))
                    {
                        throw new Exception(entry.Name + " has duplicate pick: " + pick.TeamAbbrev);
                    }
                    teamsPicked.Add(pick.TeamAbbrev);

                    if (pointsPicked.Contains(pick.Points))
                    {
                        throw new Exception(entry.Name + " has duplicate points: " + pick.Points);
                    }
                    pointsPicked.Add(pick.Points);

                    Matchup m = Matchups.FirstOrDefault(x => x.Away.Equals(pick.TeamAbbrev) || x.Home.Equals(pick.TeamAbbrev));
                    if (m == null)
                    {
                        throw new Exception(entry.Name + " has a picked team not found in matchups: " + pick.TeamAbbrev);
                    }
                    if (matchupsPicked.Contains(m))
                    {
                        throw new Exception(entry.Name + " has more than one pick for a matchup: " + pick.TeamAbbrev);
                    }
                    matchupsPicked.Add(m);
                }
            }
        }