public void PredictWeek(NFLWeek week)
        {
            var suWins    = 0;
            var suLosses  = 0;
            var atsWins   = 0;
            var atsLosses = 0;
            var atsTies   = 0;

            foreach (NFLGame game in week.GameList())
            {
                var result = PredictGame(game, PredictionStorer, game.GameDate);

                Utility.Announce(result.LogResult());

                if (game.Played())
                {
                    suWins = AnnounceResult(game, result, suWins, ref suLosses, ref atsWins, ref atsTies, ref atsLosses);
                }
                Utility.Announce("------------------------------");
            }
            if (suWins + suLosses > 0)
            {
                AnnounceTotals(suWins, suLosses, atsWins, atsLosses, atsTies);
            }
        }
 public void Calculate( string season, string week )
 {
     var theWeek = new NFLWeek( season, week );
     theWeek.LoadGameList();
     foreach ( var nflStat in theWeek.GameList().Cast<NFLGame>()
         .Select( game => game.GenerateGridStatsOutput() ).SelectMany( statList => statList ) )
         PutStat( nflStat );
 }
 public void Calculate( string season, string week )
 {
     var theWeek = new NFLWeek( season, week );
     theWeek.LoadGameList();
      Announce( string.Format("{0} Games loaded for {1}:{2}",
     theWeek._gameList.Count, season, week ) );
     foreach ( var nflStat in theWeek.GameList().Cast<NFLGame>()
         .Select( game => game.GenerateYahooOutput() ).SelectMany( statList => statList ) )
         PutStat( nflStat );
 }
        public void Calculate( string season, string week )
        {
            var theWeek = new NFLWeek( season, week );
             if (!theWeek.HasPassed()) return;

            theWeek.LoadGameList();
            foreach ( var nflStat in theWeek.GameList().Cast<NFLGame>()
                .Select( game => game.GenerateStats() ).SelectMany( statList => statList ) )
                PutStat( nflStat );
        }
        /// <summary>
        ///   Have a look at a week and let us know what the best bets are
        /// </summary>
        /// <param name="week">  The NFL week to look at</param>
        /// <returns> A collection of plays </returns>
        public ArrayList Consider(NFLWeek week)
        {
            Week    = week.Week;
            theWeek = week;

            ArrayList betList = new ArrayList();

            foreach (NFLGame g in week.GameList())
            {
                ConsiderGame(g, ref betList);
            }

            foreach (NFLGame g in week.GameList())
            {
                RemoveGameOnConflict(g, ref betList);
            }

            return(betList);
        }
Exemple #6
0
        public void Calculate(string season, string week)
        {
            var theWeek = new NFLWeek(season, week);

            theWeek.LoadGameList();
            foreach (var nflStat in theWeek.GameList().Cast <NFLGame>()
                     .Select(game => game.GenerateYahooOutput()).SelectMany(statList => statList))
            {
                PutStat(nflStat);
            }
        }
        public string Seed(NFLWeek week)
        {
            var gameSeed = "";

            foreach (NFLGame game in week.GameList())
            {
                gameSeed = game.Id;
                break;
            }
            return(gameSeed);
        }
        private static void BuildReportDataset(SimpleTableReport str, string fTeamOwner, NFLWeek week, GsTeam t)
        {
            if (week != null)
            {
                if ((t != null) && (t.OwnerId == fTeamOwner))
                {
                    foreach (NFLGame g in week.GameList())
                    {
                        if (g != null)
                        {
                            var theGame = g.Hour == null ? new NFLGame(g.GameKey()) : g;
                            //RosterLib.Utility.Announce(string.Format("Doing game {0}", theGame.GameCode ) );
                            var dr = str.Body.NewRow();
                            //RosterLib.Utility.Announce(string.Format("Rating game {0}", theGame.GameCode));
                            dr["RATING"] = t.RateGame(theGame);
                            //RosterLib.Utility.Announce(string.Format("Setting Day {0}", theGame.GameCode));
                            dr["DAY"] = string.Format("{0} {1}",
                                                      theGame.AussieDateTime().DayOfWeek.ToString().Substring(0, 3),
                                                      theGame.AussieDateTime().Day);
                            //RosterLib.Utility.Announce(string.Format("Setting Hour {0}", theGame.GameCode));
                            dr["HOUR"] = theGame.AussieHour(false);
                            //RosterLib.Utility.Announce(string.Format("Setting Names {0}",theGame.GameCode));
                            dr["AT"] = theGame.AwayNflTeam == null ? theGame.AwayTeam : theGame.AwayNflTeam.Name;
                            dr["HT"] = theGame.AwayNflTeam == null ? theGame.HomeTeam : theGame.HomeNflTeam.Name;
                            //RosterLib.Utility.Announce(string.Format("Setting TV {0}", theGame.GameCode));
                            dr["TV"] = theGame.IsOnTv ? "*" : "";
                            //RosterLib.Utility.Announce(string.Format("Setting Spread Fav {0}", theGame.GameCode));

                            dr["FAV"] = theGame.SpreadFavourite();
                            //RosterLib.Utility.Announce(string.Format("Setting Spread {0}", theGame.GameCode));
                            dr["SPREAD"] = theGame.Spread.ToString();
                            //RosterLib.Utility.Announce(string.Format("Setting myTip {0}", theGame.GameCode));
                            if (theGame.MyTip != null)
                            {
                                if (theGame.MyTip.Trim().Length > 0)
                                {
                                    dr["TIP"] = Equals(theGame.MyTip.Substring(0, 1), "H") ? theGame.HomeTeam : theGame.AwayTeam;
                                }
                            }

                            str.Body.Rows.Add(dr);
                        }
                    }
                }
            }
            else
            {
                Utility.Announce(string.Format("BuildReportDataSet: null week"));
            }
        }
        public string Seed(NFLWeek week)
        {
            var gameSeed = "";

            foreach (NFLGame game in week.GameList())
            {
                gameSeed = game.Id;
                if (!string.IsNullOrEmpty(gameSeed))
                {
                    break;
                }
            }
            LogIt($"Game Seed: {gameSeed}");
            return(gameSeed);
        }
Exemple #10
0
        public void Calculate(string season, string week)
        {
            var theWeek = new NFLWeek(season, week);

            if (!theWeek.HasPassed())
            {
                return;
            }

            theWeek.LoadGameList();
            foreach (var nflStat in theWeek.GameList().Cast <NFLGame>()
                     .Select(game => game.GenerateStats()).SelectMany(statList => statList))
            {
                PutStat(nflStat);
            }
        }
Exemple #11
0
 public void LoadRegularWeeksToDate()
 {
     RegularWeeks = new List <NFLWeek>();
     for (var i = 1; i <= WeeksIntheRegularSeason; i++)
     {
         var week     = new NFLWeek(Year, i);
         var gameList = week.GameList();
         foreach (NFLGame game in gameList)
         {
             if (!game.Played())
             {
                 break;
             }
         }
         RegularWeeks.Add(week);
     }
 }
        public int DownloadWeek(NFLWeek week)
        {
            var gameDict = new Dictionary <string, NFLGame>();
            var dlCount  = 0;
            var seed     = Int32.Parse(Seed(week));

            foreach (NFLGame game in week.GameList())
            {
                if (game.GameDate <= DateTime.Now)
                {
                    gameDict.Add(game.Index(), game);
                }
                //Console.WriteLine("{0} : {1} : {2} : {3}",game.GameName(), game.GameApKey(), game.Id,  game.Index() );
            }
            var list = gameDict.Keys.ToList();

            list.Sort();

            // Loop through keys.
            foreach (var key in list)
            {
                //Console.WriteLine("{0}: {1}", key, gameDict[key]);
                var g = gameDict[key];
                if (g.Id == "0")
                {
                    g.Id = seed.ToString();
                }
                var url = g.GamebookUrl();
                Console.WriteLine(url);
                var uri = new Uri(url);
                if (!Downloader.GotIt(uri))
                {
                    if (Downloader.DownloadPdf(uri))
                    {
                        dlCount++;
                    }
                }
                seed++;
                Console.WriteLine("");
            }
            Console.WriteLine("{0} downloaded", dlCount);
            return(dlCount);
        }
        private string GenerateBody()
        {
            var bodyOut = new StringBuilder();

            bodyOut.AppendLine(string.Format("Recording actual metrics for Week {0}:{1}", Season, Week));
            bodyOut.AppendLine();

            // Foreach game in the week
            var theWeek = new NFLWeek(Season, Week);

            theWeek.LoadGameList();
            foreach (NFLGame game in theWeek.GameList())
            {
                var homeList = game.LoadLineupPlayers(game.HomeTeam);
                TallyMetrics(bodyOut, game, homeList);

                var awayList = game.LoadLineupPlayers(game.AwayTeam);
                TallyMetrics(bodyOut, game, awayList);
            }

            return(bodyOut.ToString());
        }
Exemple #14
0
        private static void LoadData( DataTable dt, string season, string weekIn )
        {
            var week = new NFLWeek( season, weekIn );
             //  carry forward all the old ratings to cover the bye situatuins,
             //  but dont override adjustments
             var s = Masters.Sm.GetSeason( season );
             foreach ( string key in s.TeamKeyList )
             {
            NflTeam t = Masters.Tm.GetTeam( key );
            t.LetterRating[ Int32.Parse( weekIn ) ] = t.LetterRating[ Int32.Parse( weekIn ) - 1 ];
            t.NumberRating[ Int32.Parse( weekIn ) ] = t.NumberRating[ Int32.Parse( weekIn ) - 1 ];
            Masters.Sm.IsDirty = true;
             }
             var previousWeek = Int32.Parse( weekIn ) - 1;
             foreach ( NFLGame g in week.GameList() )
             {
            var dr = dt.NewRow();

            if (g.HomeNflTeam == null) g.HomeNflTeam = Masters.Tm.GetTeam( g.Season, g.HomeTeam );
            if (g.AwayNflTeam == null) g.AwayNflTeam = Masters.Tm.GetTeam(g.Season, g.AwayTeam);

            dr[ "HOME" ] = g.HomeTeamName + " " + HtmlLib.Bold( Emoticons( g.HomeNflTeam, g.AwayNflTeam, g ) );
            dr[ "AWAY" ] = g.AwayTeamName + " " + HtmlLib.Bold( Emoticons( g.AwayNflTeam, g.HomeNflTeam, g ) );
            dr[ "SPREAD" ] = g.Spread;
            var gline = GordanLine( g );
            var hLetter = g.HomeNflTeam.LetterRating[ previousWeek ];
            dr[ "HOMELETTER" ] = hLetter;
            var aLetter = g.AwayNflTeam.LetterRating[ previousWeek ];
            dr[ "AWAYLETTER" ] = aLetter;
            dr[ "HSR" ] = g.HomeNflTeam.SpreadRange( season, string.Format( "{0:00}", previousWeek ) );
            dr[ "ASR" ] = g.AwayNflTeam.SpreadRange( season, string.Format( "{0:00}", previousWeek ) );
            dr[ "GLINE" ] = gline;
            dr[ "MYTIP" ] = g.MyLine();
            dr[ "DIFF" ] = g.Spread - gline;
            dr[ "BET" ] = WhatsTheBet( g, gline );
            if ( g.Played() )
            {
               dr[ "RESULT" ] = GordanResult( g );
               dr[ "HOMESCORE" ] = g.HomeScore;
               dr[ "AWAYSCORE" ] = g.AwayScore;
               dr[ "ADJUST" ] = NumberAdjustment( g );
            }
            dt.Rows.Add( dr );
            if ( g.Played() )
            {
               //  update rankings
               g.HomeNflTeam.NumberRating[ Int32.Parse( weekIn ) ] =
                  HomeAdjustment( g.HomeScore, g.AwayScore, g.GordanLine ) +
                  g.HomeNflTeam.NumberRating[ Int32.Parse( weekIn ) - 1 ];
               g.AwayNflTeam.NumberRating[ Int32.Parse( weekIn ) ] =
                  AwayAdjustment( g.AwayScore, g.HomeScore, g.GordanLine ) +
                  g.AwayNflTeam.NumberRating[ Int32.Parse( weekIn ) - 1 ];
               // carry the letter ratings too
               g.HomeNflTeam.LetterRating[ Int32.Parse( weekIn ) ] =
                  g.HomeNflTeam.LetterRating[ Int32.Parse( weekIn ) - 1 ];
               g.AwayNflTeam.LetterRating[ Int32.Parse( weekIn ) ] =
                  g.AwayNflTeam.LetterRating[ Int32.Parse( weekIn ) - 1 ];
               Masters.Sm.IsDirty = true;
            }
             }
        }
Exemple #15
0
        /// <summary>
        ///   Have a look at a week and let us know what the best bets are
        /// </summary>
        /// <param name="week">  The NFL week to look at</param>
        /// <returns> A collection of plays </returns>
        public ArrayList Consider( NFLWeek week )
        {
            Week = week.Week;
             theWeek = week;

             ArrayList betList = new ArrayList();

             foreach ( NFLGame g in week.GameList() )
            ConsiderGame( g, ref betList );

             foreach ( NFLGame g in week.GameList() )
            RemoveGameOnConflict( g, ref betList );

             return betList;
        }
        private string GenerateBody()
        {
            var bodyOut = new StringBuilder();
             bodyOut.AppendLine(string.Format("Recording actual metrics for Week {0}:{1}", Season, Week ) );
             bodyOut.AppendLine();

             // Foreach game in the week
             var theWeek = new NFLWeek(Season, Week);
             theWeek.LoadGameList();
             foreach (NFLGame game in theWeek.GameList())
             {
            var homeList = game.LoadLineupPlayers(game.HomeTeam);
            TallyMetrics( bodyOut, game, homeList);

            var awayList = game.LoadLineupPlayers(game.AwayTeam);
            TallyMetrics(bodyOut, game, awayList);
             }

             return bodyOut.ToString();
        }
        public void PredictWeek( NFLWeek week )
        {
            var suWins = 0;
            var suLosses = 0;
            var atsWins = 0;
            var atsLosses = 0;
            var atsTies = 0;

            foreach ( NFLGame game in week.GameList() )
            {
                var result = PredictGame( game, PredictionStorer, game.GameDate );

                Utility.Announce( result.LogResult() );

                if (game.Played())
                    suWins = AnnounceResult( game, result, suWins, ref suLosses, ref atsWins, ref atsTies, ref atsLosses );
                Utility.Announce( "------------------------------" );
            }
            if (suWins + suLosses > 0)
                AnnounceTotals( suWins, suLosses, atsWins, atsLosses, atsTies );
        }
        public int DownloadWeek(
            NFLWeek week)
        {
            var gameDict = new Dictionary <string, NFLGame>();
            var dlCount  = 0;
            var seed     = Int32.Parse(Seed(week));

            if (seed == 0)
            {
                LogIt("Unable to read Game Seed");
                return(seed);
            }
            else
            {
                Console.WriteLine($"Game Seed is {seed}");
            }

            var origSeed = seed;
            var lastSeed = seed;

            foreach (NFLGame game in week.GameList())
            {
                if (game.GameDate <= DateTime.Now)
                {
                    gameDict.Add(game.Index(), game);
                }
                LogIt(
                    $@"{
						game.GameName()
						} : {
						game.GameApKey()
						} : {
						game.Id
						} : {
						game.Index()
						}"                        );
            }
            var list = gameDict.Keys.ToList();

            list.Sort();

            // Loop through keys.
            foreach (var key in list)
            {
                LogIt($"{key}: {gameDict[key]}");
                var g = gameDict[key];
                if (g.Id == "0")
                {
                    g.Id = seed.ToString();
                }
                var gotIt    = false;
                var offSet   = -2;
                var attempts = 16;
                while (!gotIt)
                {
                    var url = g.GamebookUrl();
                    LogIt($"trying:-{url}");
                    var uri = new Uri(url);
                    if (Downloader.GotIt(uri))
                    {
                        LogIt($"  got {url}");
                        lastSeed = string.IsNullOrEmpty(g.Id) ? origSeed : Int32.Parse(g.Id);
                        break;
                    }
                    else
                    {
                        if (Downloader.DownloadPdf(uri))
                        {
                            dlCount++;
                            LogIt($"Downloaded {uri} OK!");
                            lastSeed = string.IsNullOrEmpty(g.Id) ? origSeed : Int32.Parse(g.Id);
                        }
                        else
                        {
                            offSet++;
                            var nextId = lastSeed + offSet;
                            if (offSet > 1 * attempts)
                            {
                                LogIt($"{attempts} attempts made giving up");
                                break;
                            }
                            g.Id = nextId.ToString();
                        }
                    }
                }
                seed++;
            }
            LogIt($"{dlCount} downloaded");
            return(dlCount);
        }
 public void TestWeeklyProjection()
 {
     var w = new NFLWeek( "2014", "06" );
     var sut = new PlayerProjectionGenerator(null);
     var nGames = 0;
     for ( var i = 0; i < w.GameList().Count; i++ )
     {
         var game = (NFLGame) w.GameList()[ i ];
         sut.Execute( game );
         nGames++;
     }
     Assert.IsTrue( nGames > 10 && nGames < 17 );
 }
        private static void BuildReportDataset(SimpleTableReport str, string fTeamOwner, NFLWeek week, GsTeam t)
        {
            if (week != null)
            {
                if ( ( t != null ) && ( t.OwnerId == fTeamOwner ) )
                {
                    foreach ( NFLGame g in week.GameList() )
                    {
                        if ( g != null )
                        {
                            var theGame = g.Hour == null ? new NFLGame( g.GameKey() ) : g;
                            //RosterLib.Utility.Announce(string.Format("Doing game {0}", theGame.GameCode ) );
                            var dr = str.Body.NewRow();
                            //RosterLib.Utility.Announce(string.Format("Rating game {0}", theGame.GameCode));
                            dr[ "RATING" ] = t.RateGame( theGame );
                            //RosterLib.Utility.Announce(string.Format("Setting Day {0}", theGame.GameCode));
                            dr[ "DAY" ] = string.Format( "{0} {1}",
                                                                  theGame.AussieDateTime().DayOfWeek.ToString().Substring( 0, 3 ),
                                                                  theGame.AussieDateTime().Day );
                            //RosterLib.Utility.Announce(string.Format("Setting Hour {0}", theGame.GameCode));
                            dr[ "HOUR" ] = theGame.AussieHour( false );
                            //RosterLib.Utility.Announce(string.Format("Setting Names {0}",theGame.GameCode));
                            dr[ "AT" ] = theGame.AwayNflTeam == null ? theGame.AwayTeam : theGame.AwayNflTeam.Name;
                            dr[ "HT" ] = theGame.AwayNflTeam == null ? theGame.HomeTeam : theGame.HomeNflTeam.Name;
                            //RosterLib.Utility.Announce(string.Format("Setting TV {0}", theGame.GameCode));
                            dr[ "TV" ] = theGame.IsOnTv ? "*" : "";
                            //RosterLib.Utility.Announce(string.Format("Setting Spread Fav {0}", theGame.GameCode));

                            dr[ "FAV" ] = theGame.SpreadFavourite();
                            //RosterLib.Utility.Announce(string.Format("Setting Spread {0}", theGame.GameCode));
                            dr[ "SPREAD" ] = theGame.Spread.ToString();
                            //RosterLib.Utility.Announce(string.Format("Setting myTip {0}", theGame.GameCode));
                            if ( theGame.MyTip != null )
                            {
                                if ( theGame.MyTip.Trim().Length > 0 )
                                    dr[ "TIP" ] = Equals( theGame.MyTip.Substring( 0, 1 ), "H" ) ? theGame.HomeTeam : theGame.AwayTeam;
                            }

                            str.Body.Rows.Add( dr );
                        }
                    }
                }
            }
            else
                Utility.Announce(string.Format("BuildReportDataSet: null week"));
        }
Exemple #21
0
        public ArrayList LoadGamesFrom(string sStartSeason, string sStartWeek, int offset)
        {
            if (GameList == null) GameList = new ArrayList();
             GameList.Clear();

             var processWeek = new NFLWeek(Int32.Parse(sStartSeason), Int32.Parse(sStartWeek), true);

             if (offset > 0)
             {
            for (var i = 0; i < offset; i++)
            {
               foreach (var game in processWeek.GameList())
                  GameList.Add(game);
               processWeek = processWeek.NextWeek(processWeek);
            }
             }
             else
             {
            //  going backwards
            for (var i = 0; i > offset; i--)
            {
               //  process week
            #if DEBUG
               Utility.Announce(string.Format("  getting {0} game for {1} wk {2} ",
                 Name, processWeek.Season, processWeek.Week));
            #endif
               var dr = Utility.TflWs.GetGame(processWeek.Season,
                             string.Format("{0:00}", Int32.Parse(processWeek.Week)), TeamCode);
               if (dr != null)
               {
                  var myGame = new NFLGame(dr);
                  GameList.Add(myGame);
               }
               processWeek = processWeek.PreviousWeek(processWeek, false, regularSeasonGamesOnly: true);
            }
             }
             return GameList;
        }