Example #1
0
        public void TestAllRushingUnits2013()
        {
            var errors = 0;
            var s      = new NflSeason("2013", true);

            foreach (var t in s.TeamList)
            {
                t.LoadRushUnit();
                Utility.Announce(string.Format("Loaded {0} runners for {1}", t.RushUnit.Runners.Count, t.Name));
                if (t.RushUnit.AceBack != null)
                {
                    Utility.Announce(string.Format("Ace Back is {0}", t.RushUnit.AceBack.PlayerName));
                }
                if (t.RushUnit.GoalLineBack != null)
                {
                    Utility.Announce(string.Format("GoalLine Back is {0}", t.RushUnit.GoalLineBack.PlayerName));
                }
                else
                {
                    Utility.Announce("GoalLine Back is missing");
                }

                if (t.RushUnit.HasIntegrityError())
                {
                    errors++;
                    Utility.Announce(string.Format("Need to fix {0}", t.Name));
                }
            }
            Assert.AreEqual(0, errors);
        }
Example #2
0
        public void TestSeasonProjection2013()
        {
            var season = new NflSeason("2013", loadGames: false, loadDivisions: true);

            season.Predict();
            Assert.IsTrue(true);
        }
        public override string DoJob()
        {
            StartRun();
            var ppg = new PlayerProjectionGenerator( playerCache: null );
            var gameList = new ArrayList();

             //  do any unplayed games
             Logger.Debug( "   Doing whole season" );
            var s = new NflSeason( TimeKeeper.Season, loadGames: true, loadDivisions: false ); //  long time to load
            foreach ( var game in s.GameList )
                if (! game.Played() )
               gameList.Add( game );

            var nGames = 0;
            foreach ( var game in gameList.Cast<NFLGame>() )
            {
                ppg.Execute( game );
                nGames++;
            }
            //  records will be in the PGMETRIC table

            StopRun();

            var finishedMessage = string.Format( "Generated projections for {0} games", nGames );
            Logger.Info( "  {0}", finishedMessage );
            return finishedMessage;
        }
 public void Calculate( string season )
 {
     var theSeason = new NflSeason( season );
     theSeason.LoadRegularWeeksToDate();
     foreach ( var week in theSeason.RegularWeeks )
         Calculate( theSeason.Year, week.Week );
 }
Example #5
0
 public void Render()
 {
     NflSeason = new NflSeason( Year, loadGames: false, loadDivisions: false);
      NflSeason.LoadRegularWeeks();
      var str = new SimpleTableReport( string.Format( "Score Grid {0}-{1}", NflSeason.Year, ScopeInFocus ) ) { ReportHeader = ScopeInFocus };
      StyleHelper.AddStyle( str );
      str.ColumnHeadings = true;
      str.DoRowNumbers = false;
      str.ShowElapsedTime = false;
      str.IsFooter = false;
      str.AddColumn( new ReportColumn( "Stat", "STAT", "{0}" ) );
      str.AddColumn( new ReportColumn( "Total", "TOT", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk01", "WK01", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk02", "WK02", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk03", "WK03", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk04", "WK04", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk05", "WK05", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk06", "WK06", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk07", "WK07", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk08", "WK08", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk09", "WK09", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk10", "WK10", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk11", "WK11", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk12", "WK12", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk13", "WK13", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk14", "WK14", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk15", "WK15", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk16", "WK16", "{0}" ) );
      str.AddColumn( new ReportColumn( "Wk17", "WK17", "{0}" ) );
      str.LoadBody( BuildTable() );
      //str.SubHeader = SubHeading();
      str.RenderAsHtml( FileName(), true );
 }
Example #6
0
        public GordanRanks( string season )
        {
            //  set up data
             s = Masters.Sm.GetSeason( season );

             DefineData();
             LoadData();
             Render();
        }
Example #7
0
 private static void WriteConferenceList(XmlWriter writer, NflSeason s)
 {
     writer.WriteStartElement("conference-list");
     //  Division List
     foreach (NflConference c in s.ConferenceList)
     {
         WriteConferenceNode(writer, c);
     }
     writer.WriteEndElement();
 }
Example #8
0
 public void Calculate( string season )
 {
     var theSeason = new NflSeason( season );
     theSeason.LoadRegularWeeksToDate();
     foreach ( var week in theSeason.RegularWeeks )
     {
         var theWeek = string.Format( "{0:0#}", week.WeekNo );
         Utility.Announce( string.Format( "Doing week {0} of {1}", week.WeekNo, season ) );
         Calculate( theSeason.Year, theWeek );
     }
 }
Example #9
0
 public void Calculate( string season )
 {
     var theSeason = new NflSeason( season );
     theSeason.LoadRegularWeeksToDate();
     foreach ( var week in theSeason.RegularWeeks )
     {
         Announce( string.Format( "YahooMaster:Calculate Season {0} Week {1}",
        season, week.WeekNo ) );
         Calculate( theSeason.Year, week.Week );
     }
 }
 public override void RenderAsHtml()
 {
     NflSeason = new NflSeason( TimeKeeper.CurrentSeason(), loadGames: true, loadDivisions: false );
      foreach ( var game in NflSeason.GameList )
      {
     game.WriteProjection();
     #if DEBUG
     if (game.WeekNo > 1 )break;
     #endif
      }
 }
Example #11
0
 public void SaveTipsFor( string season )
 {
     var theSeason = new NflSeason( season );
     foreach ( var game in theSeason.GameList )
     {
         if ( game.Spread > 0 )
         {
             game.CalculateSpreadResult();
             Storer.StorePrediction( "bookie", game, game.BookieTip );
         }
     }
 }
Example #12
0
        public void SaveTipsFor(string season)
        {
            var theSeason = new NflSeason(season);

            foreach (var game in theSeason.GameList)
            {
                if (game.Spread > 0)
                {
                    game.CalculateSpreadResult();
                    Storer.StorePrediction("bookie", game, game.BookieTip);
                }
            }
        }
Example #13
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();
        }
 public void TestAllLoadAnalysis()
 {
     const string week = "07"; //  the week we are looking at the stats of
      var season = Utility.CurrentSeason();
      var s = new NflSeason(season, true);
      foreach (var t in s.TeamList)
      {
     t.LoadRushUnit();
     t.RushUnit.LoadCarries(season, week);
     t.LoadPassUnit();
     t.PassUnit.AnalyseQuarterbacks(season, week);
     t.PassUnit.AnalyseWideouts(season, week);
     t.PassUnit.AnalyseTightends(season, week);
      }
 }
Example #15
0
        public void TestAllLoadAnalysis()
        {
            var week   = "14";            //  the week we are looking at the stats of
            var season = Utility.CurrentSeason();
            var s      = new NflSeason(season, true);

            foreach (var t in s.TeamList)
            {
                t.LoadRushUnit();
                t.RushUnit.LoadCarries(season, week);
                t.LoadPassUnit();
                t.PassUnit.AnalyseQuarterbacks(season, week);
                t.PassUnit.AnalyseWideouts(season, week);
                t.PassUnit.AnalyseTightends(season, week);
            }
        }
Example #16
0
        public void TestAllKickers()
        {
            //TODO:  This is really a data integrity test
            var errors = 0;
            var s      = new NflSeason("2013", true);

            foreach (var t in s.TeamList)
            {
                var kicker = t.SetKicker();
                if (kicker == null)
                {
                    errors++;
                }
            }
            Utility.Announce(string.Format("There are {0} broken teams", errors));
            Assert.AreEqual(0, errors);
        }
Example #17
0
        public void TestAllPassingUnits2013()
        {
            var errors = 0;
            var s      = new NflSeason("2013", true);

            foreach (var t in s.TeamList)
            {
                t.LoadPassUnit();
                if (t.PassUnit.HasIntegrityError())
                {
                    errors++;
                    Utility.Announce(string.Format("   Need to fix {0}", t.Name));
                }
            }
            Utility.Announce(string.Format("   There are {0} broken teams", errors));
            Assert.AreEqual(0, errors);
        }
 public void TestAllDepthCharts()
 {
     const string theSeason = "2015";
      var errors = 0;
      var errorTeams = string.Empty;
      var s = new NflSeason( theSeason, true );
      foreach (var t in s.TeamList)
      {
     var isError = false;
     var sut = new DepthChartReport( theSeason, t.TeamCode );
     sut.Execute();
     if (sut.HasIntegrityError())
     {
        isError = true;
        sut.DumpErrors();
        Utility.Announce(string.Format("   Need to fix Depth Chart {0}", t.Name));
     }
     t.LoadRushUnit();
     if (t.RushUnit.HasIntegrityError())
     {
        isError = true;
        t.RushUnit.DumpUnit();
        t.RushUnit.DumpErrors();
        Utility.Announce(string.Format("   Need to fix  Rushing Unit {0}", t.Name));
     }
     t.LoadPassUnit();
     if (t.PassUnit.HasIntegrityError())
     {
        isError = true;
        t.PassUnit.DumpUnit();
        t.PassUnit.DumpErrors();
        Utility.Announce(string.Format("   Need to fix  Passing Unit {0}", t.Name));
     }
     if (isError)
     {
        errorTeams += t.TeamCode + ",";
        errors++;
     }
      }
      Utility.Announce("   -------------------------------------------------");
      Utility.Announce(string.Format("   There are {0} broken teams - {1}", errors, errorTeams));
      Utility.Announce("   -------------------------------------------------");
      Assert.AreEqual(0, errors);
 }
Example #19
0
        public void TipSeason(string season)
        {
            //  load a season
            var nflSeason        = new NflSeason(season);
            var predictionStorer = new DbfPredictionStorer();
            var mp = new MillerPredictor {
                AuditTrail = true
            };

            //  for each game
            foreach (NFLGame game in nflSeason.GameList)
            {
                if (!game.IsPlayoff())
                {
                    //    predict game
                    var result = mp.PredictGame(game, predictionStorer, game.GameDate);
                }
            }
        }
Example #20
0
        public void TestAllDepthCharts2013()
        {
            var errors     = 0;
            var errorTeams = string.Empty;
            var s          = new NflSeason("2013", true);

            foreach (var t in s.TeamList)
            {
                var isError = false;
                var sut     = new DepthChartReport("2013", t.TeamCode);
                sut.Execute();
                if (sut.HasIntegrityError())
                {
                    isError = true;
                    sut.DumpErrors();
                    Utility.Announce(string.Format("   Need to fix Depth Chart {0}", t.Name));
                }
                t.LoadRushUnit();
                if (t.RushUnit.HasIntegrityError())
                {
                    isError = true;
                    t.RushUnit.DumpUnit();
                    Utility.Announce(string.Format("   Need to fix  Rushing Unit {0}", t.Name));
                }
                t.LoadPassUnit();
                if (t.PassUnit.HasIntegrityError())
                {
                    isError = true;
                    t.PassUnit.DumpUnit();
                    Utility.Announce(string.Format("   Need to fix  Passing Unit {0}", t.Name));
                }
                if (isError)
                {
                    errorTeams += t.TeamCode + ",";
                    errors++;
                }
            }
            Utility.Announce("   -------------------------------------------------");
            Utility.Announce(string.Format("   There are {0} broken teams - {1}", errors, errorTeams));
            Utility.Announce("   -------------------------------------------------");
            Assert.AreEqual(0, errors);
        }
Example #21
0
 public NibbleRanker( string season )
 {
     _mSeason = Masters.Sm.GetSeason( season );
 }
        public override void RenderAsHtml()
        {
            var aceRepository = new AceRepository();
             var teamLines = new List<String>();
             var week = Utility.PreviousWeekAsString();
             Logger.Trace( string.Format( "Analysing roles from week {0}", week  ) );

             List<NflTeam> teamList;
             if (string.IsNullOrEmpty( SingleTeam ))
             {
            var s = new NflSeason( Season, true );
            teamList = s.TeamList;
             }
             else
            teamList = new List<NflTeam> {new NflTeam( SingleTeam )};

             foreach ( var t in teamList )
             {
            teamLines.Clear();
            teamLines.Add( "------------------------------------------------------------"  );
            teamLines.Add( t.NameOut() );
            teamLines.Add( "------------------------------------------------------------" );
            t.LoadRushUnit();
            teamLines.Add( "Runningbacks" + Environment.NewLine );
            teamLines.AddRange( t.RushUnit.LoadCarries( Season, week ) );
            teamLines.Add( Environment.NewLine );

            if (t.RushUnit.IsAceBack && t.RushUnit.AceBack.TotStats.Touches > 10)
               AddAceLine( t.RushUnit.AceBack, aceRepository );

            t.LoadPassUnit();
            teamLines.Add( "Quarterbacks" + Environment.NewLine );
            teamLines.AddRange( t.PassUnit.AnalyseQuarterbacks( Season, week ) );
            teamLines.Add( Environment.NewLine );

            teamLines.Add( "Wideouts" + Environment.NewLine );
            teamLines.AddRange( t.PassUnit.AnalyseWideouts( Season, week ) );
            teamLines.Add( Environment.NewLine );

            if ( t.PassUnit.IsAceReceiver && t.PassUnit.AceReceiver.TotStats.Touches > 5 )
               AddAceLine(t.PassUnit.AceReceiver, aceRepository);

            teamLines.Add( "Tight Ends" + Environment.NewLine );
            teamLines.AddRange( t.PassUnit.AnalyseTightends( Season, week ) );
            teamLines.Add( Environment.NewLine );

            if ( t.PassUnit.IsAceTightEnd && t.PassUnit.AceTightEnd.TotStats.Touches > 5 )
               AddAceLine(t.PassUnit.AceTightEnd, aceRepository);

            Lines.AddRange( teamLines );
            DumpTeam( teamLines, week, t );
            #if DEBUG2
            break;
            #endif
             }
             DumpLines( week );
             Finish();
             DumpAces( week );
        }
 public SpreadPredictionGenerator(string season, IStorePredictions predictionStorer)
 {
     Season            = new NflSeason(season);
     _predictionStorer = predictionStorer;
 }
Example #24
0
 public NflSeason GetSeason(string season, bool teamsOnly )
 {
     NflSeason s;
      if (TheHt.ContainsKey(season))
      {
     s = (NflSeason)TheHt[season];
     CacheHits++;
      }
      else
      {
     //  new it up
     s = new NflSeason( season, teamsOnly );
     PutSeason(s);
     CacheMisses++;
      }
      return s;
 }
Example #25
0
        private static void WriteTeamList(XmlWriter writer, NflSeason s)
        {
            writer.WriteStartElement("team-list");
            foreach (NflTeam t in s.TeamList )
            {
                writer.WriteStartElement("team");
                WriteElement( writer, "id", t.TeamCode );
                WriteElement( writer, "name", t.Name);
                WriteElement( writer, "division", t.Division());

                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
Example #26
0
        private static void WriteSeasonNode( XmlWriter writer, NflSeason s )
        {
            writer.WriteStartElement( "season" );
            WriteElement( writer, "year", s.Year );
            WriteElement( writer, "weeks-in-season", s.Weeks.ToString() );

            WriteConferenceList( writer, s );

            WriteTeamList( writer, s );

            writer.WriteEndElement();
        }
Example #27
0
 public void Render(string season)
 {
     SeasonMaster = SetSeasonMaster( season );
       foreach (string teamKey in SeasonMaster.TeamKeyList)
      {
     TeamUnits( season, teamKey );
     #if DEBUG
     break;
     #endif
      }
 }
Example #28
0
 public void PutSeason( NflSeason s )
 {
     if ( ! TheHt.ContainsKey( s.Year ) )
     {
         TheHt.Add( s.Year, s );
         IsDirty = true;
     }
 }
Example #29
0
 private static void WriteTeamList( XmlTextWriter writer, NflSeason s )
 {
     writer.WriteStartElement( "team-list" );
     foreach ( string teamKey in s.TeamKeyList )
     {
         writer.WriteStartElement( "team" );
         writer.WriteAttributeString( "key", teamKey );
         WriteRatings( writer, teamKey );
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Example #30
0
 public void AddSeason( NflSeason s )
 {
     TheHt.Add( s.Year, s );
 }
Example #31
0
 public StatGrid( string season )
 {
     Season = new NflSeason( season );
      StatMaster = new StatMaster("Stats", "stats.xml");
 }
Example #32
0
 public StatGrid( string season, string statType )
 {
     Season = new NflSeason( season );
      StatInFocus = statType;
      StatMaster = new StatMaster( "Stats", "stats.xml" );
 }
        public override void RenderAsHtml()
        {
            LeagueInFocus = Constants.K_LEAGUE_Yahoo;

             var season = new NflSeason(Season, teamsOnly: true);
             foreach (var team in season.TeamList)
             {
            TeamCode = team.TeamCode;
            Execute();
            #if DEBUG2
            break;
            #endif
             }
             DumpErrors();
        }
Example #34
0
 public StatGrid( NflSeason season, string statType, StatMaster statMaster )
 {
     Season = season;
      StatInFocus = statType;
      StatMaster = statMaster;
 }
Example #35
0
 public NibbleRanker()
 {
     _mSeason = new NflSeason( Utility.CurrentSeason() );
     LoadRates();
 }
Example #36
0
 public HillenTips( string season, string week )
 {
     Season = new NflSeason( season );
     Week = new NFLWeek( season, week );
     HillenPredictor = new HillinPredictor();
 }