예제 #1
0
        public void Calculate( string season, string week )
        {
            if ( week.Equals( "01" ) )
            {
                SetupSeason( season );
                Dump2Xml();
                return;
            }

            var hp = new HillinPredictor();

            var theSeason = new NflSeason( season );

            foreach ( var team in theSeason.TeamList )
            {
                //  get teams game for the week
                Utility.Announce( string.Format( "  Doing {0}", team.TeamCode ) );
                var upcomingWeek = new NFLWeek( season, week );
                var previousWeek = upcomingWeek.PreviousWeek( upcomingWeek, loadgames:false, regularSeasonGamesOnly:true );
                var prevWeek = string.Format( "{0:0#}", previousWeek.WeekNo );
                var oldPowerRating = team.GetPowerRating( prevWeek );

                if ( oldPowerRating == 0 )
                {
                    return;
                }
                var newRating = new HillenPowerRating
                {
                    Season = season,
                    TeamCode = team.TeamCode,
                    Week = week,
                    Quantity = oldPowerRating
                };

                var game = Utility.GetGameFor( season, prevWeek, team.TeamCode );

                if ( game.GameDate != new DateTime( 1, 1, 1 ) )
                {
                    var predictedResult = hp.PredictGame( game, null, game.GameDate );
                    var predictedMarginForTeam = predictedResult.MarginForTeam( team.TeamCode );
                    //Utility.Announce( string.Format( "Predicted Margin for {0} is {1}", TeamCode, predictedMarginForTeam ) );
                    var actualMarginForTeam = game.Result.MarginForTeam( team.TeamCode );
                    //Utility.Announce( string.Format( "   Result of {2} means Actual Margin for {0} is {1}",
                    var newPowerRating = AdjustedPower( oldPowerRating, predictedMarginForTeam, actualMarginForTeam );
                    newRating.Quantity = newPowerRating;
                }
                PutRating( newRating );
            }
            Dump2Xml();
        }
예제 #2
0
        public void Calculate(string season, string week)
        {
            if (week.Equals("01"))
            {
                SetupSeason(season);
                Dump2Xml();
                return;
            }

            var hp = new HillinPredictor();

            var theSeason = new NflSeason(season);

            foreach (var team in theSeason.TeamList)
            {
                //  get teams game for the week
                Utility.Announce(string.Format("  Doing {0}", team.TeamCode));
                var upcomingWeek   = new NFLWeek(season, week);
                var previousWeek   = upcomingWeek.PreviousWeek(upcomingWeek, loadgames: false, regularSeasonGamesOnly: true);
                var prevWeek       = string.Format("{0:0#}", previousWeek.WeekNo);
                var oldPowerRating = team.GetPowerRating(prevWeek);

                if (oldPowerRating == 0)
                {
                    return;
                }
                var newRating = new HillenPowerRating
                {
                    Season   = season,
                    TeamCode = team.TeamCode,
                    Week     = week,
                    Quantity = oldPowerRating
                };

                var game = Utility.GetGameFor(season, prevWeek, team.TeamCode);

                if (game.GameDate != new DateTime(1, 1, 1))
                {
                    var predictedResult        = hp.PredictGame(game, null, game.GameDate);
                    var predictedMarginForTeam = predictedResult.MarginForTeam(team.TeamCode);
                    //Utility.Announce( string.Format( "Predicted Margin for {0} is {1}", TeamCode, predictedMarginForTeam ) );
                    var actualMarginForTeam = game.Result.MarginForTeam(team.TeamCode);
                    //Utility.Announce( string.Format( "   Result of {2} means Actual Margin for {0} is {1}",
                    var newPowerRating = AdjustedPower(oldPowerRating, predictedMarginForTeam, actualMarginForTeam);
                    newRating.Quantity = newPowerRating;
                }
                PutRating(newRating);
            }
            Dump2Xml();
        }
예제 #3
0
 public HillenTips(string season, string week)
 {
     Season          = new NflSeason(season);
     Week            = new NFLWeek(season, week);
     HillenPredictor = new HillinPredictor();
 }
예제 #4
0
        private decimal AdjustForResult(decimal teamsPowerRating, decimal opponentsPowerRating,
         NFLGame game, string teamCode)
        {
            //Utility.Announce( string.Format( "Adjusting initial rating of {0} for {2} based on the game {1}",
             //   teamsPowerRating, game.GameCodeOut(), TeamCode ) );

             //  calculate difference to prediction
             var predictor = new HillinPredictor();
             var predictedResult = predictor.PredictGame(game, null, game.GameDate);
             var predictedMarginForTeam = predictedResult.MarginForTeam(TeamCode);
             //Utility.Announce( string.Format( "Predicted Margin for {0} is {1}", TeamCode, predictedMarginForTeam ) );
             var actualMarginForTeam = game.Result.MarginForTeam(TeamCode);
             //Utility.Announce( string.Format( "   Result of {2} means Actual Margin for {0} is {1}",
             //   TeamCode, actualMarginForTeam, game.Result.LogResult() ) );
             var difference = actualMarginForTeam - predictedMarginForTeam;
             var absDiff = Math.Abs(difference);

             //  look up modifier
             var modifier = 0.0M;
             if (absDiff > 14.5M)
            modifier = 3.0M;
             else if (absDiff > 9.5M)
            modifier = 2.0M;
             else if (absDiff > 4.5M)
            modifier = 1.0M;

             if (difference < 0)
             {
            //Utility.Announce( string.Format( "Modifier for {0} is {1}",
            //   TeamCode, -modifier ) );
            return teamsPowerRating -= modifier;
             }
             //Utility.Announce( string.Format( "Modifier for {0} is {1}",
             //   TeamCode, modifier ) );
             return teamsPowerRating += modifier;
        }
예제 #5
0
 public HillenTips( string season, string week )
 {
     Season = new NflSeason( season );
     Week = new NFLWeek( season, week );
     HillenPredictor = new HillinPredictor();
 }