Ejemplo n.º 1
0
        private static int GameProjection(NFLGame g, string playerTeamCode, string playerCategory, string playerRole)
        {
            var projection = 0;

            if (playerRole == Constants.K_ROLE_STARTER)
            {
                switch (playerCategory)
                {
                case Constants.K_QUARTERBACK_CAT:
                    projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdp : g.ProjectedAwayTdp;
                    break;

                case Constants.K_RUNNINGBACK_CAT:
                    projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdr : g.ProjectedAwayTdr;
                    break;

                case Constants.K_RECEIVER_CAT:
                    projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdp / 2 : g.ProjectedAwayTdp / 2;
                    break;

                case Constants.K_KICKER_CAT:
                    projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeFg : g.ProjectedAwayFg;
                    break;
                }
            }
            return(projection);
        }
        public int PredictSteals(NflTeam team, string season, int week)
        {
            //  Predict the number of Interceptions the team will make
            int ints = 0;
            //  who are the opponents
            NflTeam opponent = team.OpponentFor(season, week);

            if (opponent != null)
            {
                //  not on a bye
                int pdInts = ConvertRating(team.PrRating());
                int poInts = ConvertRating(opponent.PpRating());
                ints += (pdInts - poInts) - 1; //  will range from 3 to -5
            }

            //  What is the Game
            NFLGame game = team.GameFor(season, week);

            if (game != null)
            {
                if (game.IsHome(team.TeamCode))
                {
                    ints += 1;
                }
            }


            if (ints < 0)
            {
                ints = 0;
            }

            return(ints);
        }
Ejemplo n.º 3
0
        public Int32 PredictTDc(NFLPlayer plyr, string season, int week)
        {
            //  Predict the number of FGs this player will kick
            int tdc = 0;

            //  starters only
            if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RECEIVER_CAT))
            {
                if (plyr.CurrTeam.Ratings.Equals("CCCCCC"))
                {
                    plyr.CurrTeam.SetRecord(season);
                }

                //  who are the opponents
                NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week);
                if (opponent != null)
                {
                    if (opponent.Ratings.Equals("CCCCCC"))
                    {
                        opponent.SetRecord(season);                                // Incase not initialised
                    }
                    //  not on a bye
                    tdc = 1;
                    int diff = ConvertRating(plyr.CurrTeam.PoRating()) - ConvertRating(opponent.PdRating());
                    if (diff > 0)
                    {
                        tdc += 1;
                    }
                    if (diff > 2)
                    {
                        tdc += 1;
                    }
                    if (diff < -2)
                    {
                        tdc -= 1;
                    }
                }

                //  What is the Game
                NFLGame game = plyr.CurrTeam.GameFor(season, week);
                if (game != null)
                {
                    if (game.IsHome(plyr.CurrTeam.TeamCode))
                    {
                        tdc += 1;
                    }
                    if (game.IsBadWeather())
                    {
                        tdc -= 1;
                    }
                }
                tdc = plyr.IsTe() ? Convert.ToInt32(tdc * .25M) : Convert.ToInt32(tdc * .5M);
            }
            return(tdc);
        }
Ejemplo n.º 4
0
        private int RankPoints(NFLPlayer player, NFLGame game)
        {
            decimal points = 0;

            points = PlayerSpread(game.GetSpread(), game.IsHome(player.CurrTeam.TeamCode));
            if (player.PlayerRole.Equals(RosterLib.Constants.K_ROLE_STARTER))
            {
                points += 14;                 //  get 2 TD if you are a starter
            }
            return((int)points);
        }
Ejemplo n.º 5
0
        public Int32 PredictTDr(NFLPlayer plyr, string season, int week)
        {
            //  Predict the number of FGs this player will kick
            int tDr = 0;

            //  starters only
            if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RUNNINGBACK_CAT) && plyr.IsRusher())
            {
                if (plyr.CurrTeam.Ratings.Equals("CCCCCC"))
                {
                    plyr.CurrTeam.SetRecord(season, skipPostseason: false);
                }

                //  who are the opponents
                NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week);
                if (opponent != null)
                {
                    if (opponent.Ratings.Equals("CCCCCC"))
                    {
                        opponent.SetRecord(season, skipPostseason: false);                                // Incase not initialised
                    }
                    //  not on a bye
                    tDr = 1;
                    int diff = ConvertRating(plyr.CurrTeam.RoRating()) - ConvertRating(opponent.RdRating());
                    if (diff > 1)
                    {
                        tDr += 1;
                    }
                    if (diff > 3)
                    {
                        tDr += 1;
                    }
                    if (diff < -1)
                    {
                        tDr -= 1;
                    }
                }

                //  What is the Game
                NFLGame game = plyr.CurrTeam.GameFor(season, week);
                if (game != null)
                {
                    if (game.IsHome(plyr.CurrTeam.TeamCode))
                    {
                        tDr += 1;
                    }
                    if (game.IsBadWeather())
                    {
                        tDr -= 1;
                    }
                }
            }
            return(tDr);
        }
Ejemplo n.º 6
0
        public int GameProjection(
            NFLGame g,
            string playerTeamCode,
            string playerCategory,
            string playerRole)
        {
            var projection = 0;

            if (playerRole != Constants.K_ROLE_STARTER)
            {
                return(projection);
            }

            //  is a starter
            switch (playerCategory)
            {
            case Constants.K_QUARTERBACK_CAT:
                projection = g.IsHome(playerTeamCode)
                                                ? g.ProjectedHomeTdp : g.ProjectedAwayTdp;
                break;

            case Constants.K_RUNNINGBACK_CAT:
                projection = g.IsHome(playerTeamCode)
                                                ? g.ProjectedHomeTdr : g.ProjectedAwayTdr;
                break;

            case Constants.K_RECEIVER_CAT:
                projection = g.IsHome(playerTeamCode)
                                                ? g.ProjectedHomeTdp / 2 : g.ProjectedAwayTdp / 2;
                break;

            case Constants.K_KICKER_CAT:
                projection = g.IsHome(playerTeamCode)
                                                ? g.ProjectedHomeFg : g.ProjectedAwayFg;
                break;
            }
#if DEBUG
            Announce($"Game {g.GameKey()} projection for {playerTeamCode} {playerCategory} {playerRole} is {projection}");
#endif
            return(projection);
        }
        public Int32 PredictSacks(
            NflTeam team,
            string season,
            int week)
        {
            //  Predict the number of Sacks the team will make
            int sacks = 0;
            //  who are the opponents
            NflTeam opponent = team.OpponentFor(
                season,
                week);

            if (opponent != null)
            {
                //  not on a bye
                sacks += 1;
                int prSacks = ConvertRating(team.PrRating());
                int ppSacks = ConvertRating(opponent.PpRating());
                sacks += (prSacks - ppSacks);
            }

            //  What is the Game
            NFLGame game = team.GameFor(season, week);

            if (game != null)
            {
                if (game.IsHome(team.TeamCode))
                {
                    sacks += 1;
                }
                if (game.IsBadWeather())
                {
                    sacks += 1;
                }
            }

            if (sacks < 0)
            {
                sacks = 0;
            }

            return(sacks);
        }
Ejemplo n.º 8
0
        public Int32 PredictFGs(NFLPlayer plyr, string season, int week)
        {
            //  Predict the number of FGs this player will kick
            int fg = 0;

            //  starters only
            if (plyr.IsStarter())
            {
                //  who does he play for
                NflTeam kickersTeam = plyr.CurrTeam;

                //  who are the opponents
                NflTeam opponent = kickersTeam.OpponentFor(season, week);
                if (opponent != null)
                {
                    //  not on a bye
                    fg += 1;
                    if (opponent.IsGoodDefence())
                    {
                        fg += 1;
                    }
                }

                //  What is the Game
                NFLGame game = kickersTeam.GameFor(season, week);
                if (game != null)
                {
                    if (game.IsHome(kickersTeam.TeamCode))
                    {
                        fg += 1;
                    }
                    if (game.IsDomeGame())
                    {
                        fg += 1;
                    }
                    if (game.IsBadWeather())
                    {
                        fg -= 1;
                    }
                }
            }
            return(fg);
        }
Ejemplo n.º 9
0
        private void LoadTeam(NflTeam team, string teamCode)
        {
            var ep        = new EpMetric();
            var metricsHt = new Hashtable();

            var dg    = _tflWs.GetAllGames(teamCode, Season);
            var games = dg.Tables["sched"];

            foreach (DataRow drg in games.Rows)
            {
                var g = new NFLGame(drg);
                if (!g.IsRecent())
                {
                    continue;
                }

                if (!g.MetricsCalculated)
                {
                    g.TallyMetrics(String.Empty);
                }
                var hashCode = string.Format("{0}{1}{2}", teamCode, g.Season, g.Week);
                if (g.IsHome(teamCode))
                {
                    ep.HomeTeam      = teamCode;
                    ep.OffTDp        = g.HomeTDp;
                    ep.OffTDr        = g.HomeTDr;
                    ep.OffSakAllowed = g.HomeSaKa;
                    ep.DefTDp        = g.AwayTDp;
                    ep.DefTDr        = g.AwayTDr;
                    ep.DefSak        = g.AwaySaKa;
                    ep.HomePasses    = g.HomePasses;
                    ep.HomeRuns      = g.HomeRuns;
                }
                else
                {
                    ep.AwayTeam      = g.AwayTeam;
                    ep.OffTDp        = g.AwayTDp;
                    ep.OffTDr        = g.AwayTDr;
                    ep.OffSakAllowed = g.AwaySaKa;
                    ep.DefTDp        = g.HomeTDp;
                    ep.DefTDr        = g.HomeTDr;
                    ep.DefSak        = g.HomeSaKa;
                    ep.AwayPasses    = g.AwayPasses;
                    ep.AwayRuns      = g.AwayRuns;
                }

                if (DoBreakdowns)
                {
                    AddBreakdown(teamCode, ep, g);
                }

                if (ep.Total() <= 0)
                {
                    continue;
                }

                ep.WeekSeed = Utility.WeekSeed(g.Season, g.Week);
                if (!metricsHt.ContainsKey(hashCode))
                {
                    metricsHt.Add(hashCode, ep);
                }
            }
            team.SetMetrics(metricsHt);
#if DEBUG
            //Utility.PrintIndexAndKeysAndValues( metricsHt );
#endif
        }
Ejemplo n.º 10
0
        //  rank points are used to sort players
        public decimal RankPoints(NFLPlayer player, NFLGame game, NflTeam opponent)
        {
            decimal points = 0;

            #region short cut

            if (RankMaster.Contains(player.PlayerCode))
            {
                var rankedPlayer = ( NFLPlayer )RankMaster[player.PlayerCode];
                return(rankedPlayer.Points);
            }

            #endregion short cut

            #region Get the average output for the last 3 games

            //  Always start with the Average points in their last 3 games, if 0 and QB use 14
            if (game != null)
            {
                if (player.PlayerRole.Equals(Constants.K_ROLE_STARTER))
                {
                    var avgPoints = AveragePoints(player);

                    //  Rookies and injured players may not have played in the last 3 games
                    if (player.PlayerCat.Equals("1"))
                    {
                        if (avgPoints.Equals(0.0M))
                        {
                            avgPoints = 14.0M;                                                      // avergage for a QB
                        }
                    }
                    if (player.PlayerCat.Equals("2"))
                    {
                        if (avgPoints.Equals(0.0M))
                        {
                            avgPoints = 8.0M;                                                      // avergage for a RB
                        }
                    }
                    if (player.PlayerCat.Equals("3"))
                    {
                        if (avgPoints.Equals(0.0M))
                        {
                            avgPoints = 6.0M;                                                      // avergage for a RB
                        }
                    }
                    else if (player.PlayerCat.Equals("4"))
                    {
                        if (avgPoints.Equals(0.0M))
                        {
                            avgPoints = 6.0M;                                                      // avergage day for a PK
                        }
                    }
                    points += avgPoints;
                }
            }

            #endregion Get the average output for the last 3 games

            #region Consider the likely result

            decimal spreadModifier = 1;              //  no modification

            if (IncludeSpread)
            {
                if (game != null)
                {
                    spreadModifier = PlayerSpread(game.GetSpread(), game.IsHome(player.CurrTeam.TeamCode)) / 1;
                }

                points *= spreadModifier;
            }

            #endregion Consider the likely result

            #region factor in the quality of the opponent

            if (IncludeRatingModifier)
            {
                if (opponent != null)
                {
                    var oppRating      = player.OpponentRating(opponent.Ratings);
                    var ratingModifier = RatingModifier(oppRating);
                    points *= ratingModifier;
                }
            }

            #endregion factor in the quality of the opponent

            player.Points = points;
            RankMaster.Add(player.PlayerCode, player);               //  save points for later

#if DEBUG
            //  verbose audit trail of the calculations
            //Announce(string.Format(
            //   "{0,-16} has {1,4:#0.#} r pts- spr {2,4:#0.#} avgFP last 3 {3,4:##.#} rating mod {4,4:#0.#} {5}",
            //   player.PlayerNameShort, points, spreadModifier, avgPoints, ratingModifier, oppRating ) );
#endif
            return(points);
        }