public Prediction Get(string method, string season, string week, string gameCode) { var prediction = new Prediction(); var ds = Utility.TflWs.GetPrediction(method, season, week, gameCode); if (ds.Tables[0].Rows.Count != 1) { return(prediction); } var game = new NFLGame(string.Format("{0}:{1}-{2}", season, week, gameCode)); prediction.Method = method; prediction.Season = season; prediction.Week = week; prediction.GameCode = gameCode; prediction.HomeScore = IntValue(ds, "HomeScore"); prediction.AwayScore = IntValue(ds, "AwayScore"); // also do a result var result = new NFLResult(home: game.HomeTeam, homePts: prediction.HomeScore, away: game.AwayTeam, awayPts: prediction.AwayScore) { HomeTDp = IntValue(ds, "htdp"), HomeTDr = IntValue(ds, "htdr"), HomeTDd = IntValue(ds, "htdd"), HomeTDs = IntValue(ds, "htds"), AwayTDp = IntValue(ds, "atdp"), AwayTDr = IntValue(ds, "atdr"), AwayTDd = IntValue(ds, "atdd"), AwayTDs = IntValue(ds, "atds"), HomeYDp = IntValue(ds, "hydp"), AwayYDp = IntValue(ds, "aydp"), HomeYDr = IntValue(ds, "hydr"), AwayYDr = IntValue(ds, "aydr"), AwayFg = IntValue(ds, "afg"), HomeFg = IntValue(ds, "hfg") }; prediction.NflResult = result; return(prediction); }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { const int avgScore = 21; var homeRating = RatingsService.GetNibbleRatingFor( game.HomeNflTeam, predictionDate ); var awayRating = RatingsService.GetNibbleRatingFor( game.AwayNflTeam, predictionDate ); var homeOff = homeRating.Offence; var homeDef = homeRating.Defence; var awayOff = awayRating.Offence; var awayDef = awayRating.Defence; var homeScore = avgScore + ((homeOff + awayDef) / 2) + 3; // 3pts home field advantage var awayScore = avgScore + ((awayOff + homeDef) / 2); homeScore = Utility.PickAScore(homeScore); awayScore = Utility.PickAScore(awayScore); if (homeScore == awayScore) homeScore++; // no ties var res = new NFLResult( game.HomeTeam, homeScore, game.AwayTeam, awayScore ); //TODO: Nibble predictor does not predict Tdp or Tdr if (AuditTrail) { AuditPrediction(game, awayDef, awayOff, homeOff, res, homeDef); if ( StorePrediction ) StorePredictedResult( game, res ); } return res; }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { var result = new NFLResult { AwayTeam = game.AwayTeam, HomeTeam = game.HomeTeam }; var homeTeam = game.HomeNflTeam; var awayTeam = game.AwayNflTeam; var nHomeOff = Utility.OffRating(homeTeam, predictionDate); var nAwayOff = Utility.OffRating(awayTeam, predictionDate); var nHomeDef = Utility.DefRating(homeTeam, predictionDate); var nAwayDef = Utility.DefRating(awayTeam, predictionDate); result.HomeScore = (nHomeOff + nAwayDef) - 20; result.AwayScore = (nAwayOff + nHomeDef) - 20; persistor.StorePrediction("Miller", game, result); if (AuditTrail) { Utility.Announce(string.Format("{0}-{1}:{2}", game.GameCodeOut(), game.GameCode, result.LogResult())); } return(result); }
private static int AnnounceResult(NFLGame game, NFLResult result, int suWins, ref int suLosses, ref int atsWins, ref int atsTies, ref int atsLosses) { Utility.Announce(game.ScoreOut()); var su = game.EvaluatePrediction(result); Utility.Announce(su); if (su.IndexOf("WIN") > -1) { suWins++; } else { suLosses++; } var ats = game.EvaluatePredictionAts(result, game.Spread); if (ats.IndexOf("WIN") > -1) { atsWins++; } else if (ats.IndexOf("PUSH") > -1) { atsTies++; } else { atsLosses++; } Utility.Announce(ats); return(suWins); }
public NFLResult PredictGame( NFLGame game, IStorePredictions persistor, DateTime predictionDate ) { if ( persistor == null ) StorePrediction = false; var homePower = game.HomeNflTeam.GetPowerRating( game.Week ); var awayPower = game.AwayNflTeam.GetPowerRating( game.Week ); //Utility.Announce( string.Format( "PredictGame: Home Power {0} v Away Power {1}", // homePower, awayPower ) ); // Add 2.5 to the Home teams power rating homePower += 2.5M; // Compare Power Rating to get the line var line = homePower - awayPower; // Estrapolate the score from the line using 21 point average var homeScore = 21.0M; var awayScore = 21.0M ; if ( line > 0 ) homeScore += line; if ( line < 0 ) awayScore -= line; var intHomeScore = Int32.Parse( Math.Round( homeScore, 0 ).ToString() ) ; var intAwayScore = Int32.Parse( Math.Round( awayScore, 0 ).ToString() ); var res = new NFLResult( game.HomeTeam, intHomeScore, game.AwayTeam, intAwayScore ); if ( StorePrediction ) StorePredictedResult( game, res ); //Utility.Announce( string.Format( "PredictGame: Result predicted - {0}", res.LogResult() ) ); return res; }
public Prediction Get( string method, string season, string week, string gameCode ) { var prediction = new Prediction(); var ds = Utility.TflWs.GetPrediction(method, season, week, gameCode); if (ds.Tables[ 0 ].Rows.Count != 1) return prediction; var game = new NFLGame( string.Format( "{0}:{1}-{2}", season, week, gameCode ) ); prediction.Method = method; prediction.Season = season; prediction.Week = week; prediction.GameCode = gameCode; prediction.HomeScore = IntValue( ds, "HomeScore" ); prediction.AwayScore = IntValue( ds, "AwayScore" ); // also do a result var result = new NFLResult( home: game.HomeTeam, homePts: prediction.HomeScore, away: game.AwayTeam, awayPts: prediction.AwayScore ) { HomeTDp = IntValue( ds, "htdp" ), HomeTDr = IntValue( ds, "htdr" ), HomeTDd = IntValue( ds, "htdd" ), HomeTDs = IntValue( ds, "htds" ), AwayTDp = IntValue( ds, "atdp" ), AwayTDr = IntValue( ds, "atdr" ), AwayTDd = IntValue( ds, "atdd" ), AwayTDs = IntValue( ds, "atds" ), HomeYDp = IntValue( ds, "hydp" ), AwayYDp = IntValue( ds, "aydp" ), HomeYDr = IntValue( ds, "hydr" ), AwayYDr = IntValue( ds, "aydr" ), AwayFg = IntValue( ds, "afg" ), HomeFg = IntValue( ds, "hfg" ) }; prediction.NflResult = result; return prediction; }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { NFLResult res; //RosterLib.Utility.Announce( string.Format( "WizPredictor.PredictGame: Wk{2} {0}@{1}", // game.AwayTeam, game.HomeTeam, game.Week ) ); if (game.Played()) { res = new NFLResult(game.HomeTeam, game.HomeScore, game.AwayTeam, game.AwayScore); } else { if (game.HomeNflTeam == null) { game.HomeNflTeam = Masters.Tm.GetTeam(game.Season, game.HomeTeam); } if (game.AwayNflTeam == null) { game.AwayNflTeam = Masters.Tm.GetTeam(game.Season, game.AwayTeam); } var homeMatrix = game.HomeNflTeam.GetMatrix(); var awayMatrix = game.AwayNflTeam.GetMatrix(); // Homescore = Tdp*7 + Tdr*7 + 3 var homePointsPassing = Tdp(homeMatrix.PoPoints - awayMatrix.PdPoints); var homePointsRunning = Tdr(homeMatrix.RoPoints - awayMatrix.RdPoints); var homeScore = homePointsPassing + homePointsRunning + 3; // Awayscore = Tdp*7 + Tdr*7 var awayPointsPassing = Tdp(awayMatrix.PoPoints - homeMatrix.PdPoints); var awayPointsRunning = Tdr(awayMatrix.RoPoints - homeMatrix.RdPoints); var awayScore = awayPointsPassing + awayPointsRunning; if (homeScore == awayScore) { homeScore++; // no ties } res = new NFLResult(game.HomeTeam, homeScore, game.AwayTeam, awayScore) { AwayTDp = (awayPointsPassing / 7), HomeTDp = (homePointsPassing / 7), AwayTDr = (awayPointsRunning / 7), HomeTDr = (homePointsRunning / 7) }; if (AuditTrail) { Utility.Announce(string.Format("Wiz Prediction Wk{4} {0}@{1} {2}-{3} ", game.AwayTeam, game.HomeTeam, res.AwayScore, res.HomeScore, game.Week)); Utility.Announce(string.Format(" hTDr({0}) hTDp({1}) aTDr({2}) aTDp({3})", res.HomeTDr, res.HomeTDp, res.AwayTDr, res.AwayTDp)); Utility.Announce(string.Format(" hPOpts({0:#.#}) hROpts({1:#.#}) aRDpts({2:#.#}) aPDpts({3:#.#})", homeMatrix.PoPoints, homeMatrix.RoPoints, awayMatrix.RdPoints, awayMatrix.PdPoints)); Utility.Announce(string.Format(" aPOpts({0:#.#}) aROpts({1:#.#}) hRDpts({2:#.#}) hPDpts({3:#.#})", awayMatrix.PoPoints, awayMatrix.RoPoints, homeMatrix.RdPoints, homeMatrix.PdPoints)); } } return(res); }
private void StorePredictedResult( NFLGame game, NFLResult nflResult) { PredictionStorer.StorePrediction( "unit", game, nflResult); }
private void AuditIt( NFLGame game, NFLResult res, int homeRating, int awayRating) { const string debugTeamCode = "SF"; var debugTeamRank = "(0-0)"; #if DEBUG var strVenue = "unknown"; #endif var oppTeamCode = "YY"; var oppRank = "(0-0)"; const string rankFormat = "({0})"; var bAudit = false; if (game.HomeTeam.Equals(debugTeamCode)) { bAudit = true; #if DEBUG strVenue = "Home"; #endif oppTeamCode = game.AwayTeam; oppRank = string.Format(rankFormat, awayRating); debugTeamRank = string.Format(rankFormat, homeRating); } if (game.AwayTeam.Equals(debugTeamCode)) { bAudit = true; #if DEBUG strVenue = "Away"; #endif oppTeamCode = game.HomeTeam; oppRank = string.Format(rankFormat, homeRating); debugTeamRank = string.Format(rankFormat, awayRating); } if (!bAudit) { return; } #if DEBUG Announce( $" {game.GameCodeOut()} Debug Team {debugTeamCode} {debugTeamRank}, is {strVenue} vs {oppTeamCode} {oppRank}"); Announce( res.LogResult()); // verbosity #endif }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { NFLResult res; //RosterLib.Utility.Announce( string.Format( "WizPredictor.PredictGame: Wk{2} {0}@{1}", // game.AwayTeam, game.HomeTeam, game.Week ) ); if ( game.Played() ) res = new NFLResult( game.HomeTeam, game.HomeScore, game.AwayTeam, game.AwayScore ); else { if ( game.HomeNflTeam == null ) game.HomeNflTeam = Masters.Tm.GetTeam( game.Season, game.HomeTeam ); if ( game.AwayNflTeam == null ) game.AwayNflTeam = Masters.Tm.GetTeam( game.Season, game.AwayTeam ); var homeMatrix = game.HomeNflTeam.GetMatrix(); var awayMatrix = game.AwayNflTeam.GetMatrix(); // Homescore = Tdp*7 + Tdr*7 + 3 var homePointsPassing = Tdp( homeMatrix.PoPoints - awayMatrix.PdPoints ); var homePointsRunning = Tdr( homeMatrix.RoPoints - awayMatrix.RdPoints ); var homeScore = homePointsPassing + homePointsRunning + 3; // Awayscore = Tdp*7 + Tdr*7 var awayPointsPassing = Tdp( awayMatrix.PoPoints - homeMatrix.PdPoints ); var awayPointsRunning = Tdr( awayMatrix.RoPoints - homeMatrix.RdPoints ); var awayScore = awayPointsPassing + awayPointsRunning; if ( homeScore == awayScore ) homeScore++; // no ties res = new NFLResult(game.HomeTeam, homeScore, game.AwayTeam, awayScore) { AwayTDp = (awayPointsPassing/7), HomeTDp = (homePointsPassing/7), AwayTDr = (awayPointsRunning/7), HomeTDr = (homePointsRunning/7) }; if ( AuditTrail ) { Utility.Announce( string.Format( "Wiz Prediction Wk{4} {0}@{1} {2}-{3} ", game.AwayTeam, game.HomeTeam, res.AwayScore, res.HomeScore, game.Week ) ); Utility.Announce( string.Format( " hTDr({0}) hTDp({1}) aTDr({2}) aTDp({3})", res.HomeTDr, res.HomeTDp, res.AwayTDr, res.AwayTDp )); Utility.Announce( string.Format( " hPOpts({0:#.#}) hROpts({1:#.#}) aRDpts({2:#.#}) aPDpts({3:#.#})", homeMatrix.PoPoints, homeMatrix.RoPoints, awayMatrix.RdPoints, awayMatrix.PdPoints )); Utility.Announce( string.Format( " aPOpts({0:#.#}) aROpts({1:#.#}) hRDpts({2:#.#}) hPDpts({3:#.#})", awayMatrix.PoPoints, awayMatrix.RoPoints, homeMatrix.RdPoints, homeMatrix.PdPoints )); } } return res; }
private string AwayLine(NFLResult prediction) { var sb = new StringBuilder(); sb.Append(HtmlLib.TableRowOpen()); sb.Append(HtmlLib.TableData(Game.AwayTeam)); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayScore, Game.AwayScore))); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayTDp, Game.AwayTDp))); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayTDr, Game.AwayTDr))); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayFg, Game.AwayFg))); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayTDd, Game.AwayTDd))); sb.Append(HtmlLib.TableData(ScoreOut(prediction.AwayTDs, Game.AwayTDs))); sb.Append(HtmlLib.TableRowClose()); return(sb.ToString()); }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { if (persistor == null) { StorePrediction = false; } var homePower = game.HomeNflTeam.GetPowerRating(game.Week); var awayPower = game.AwayNflTeam.GetPowerRating(game.Week); //Utility.Announce( string.Format( "PredictGame: Home Power {0} v Away Power {1}", // homePower, awayPower ) ); // Add 2.5 to the Home teams power rating homePower += 2.5M; // Compare Power Rating to get the line var line = homePower - awayPower; // Estrapolate the score from the line using 21 point average var homeScore = 21.0M; var awayScore = 21.0M; if (line > 0) { homeScore += line; } if (line < 0) { awayScore -= line; } var intHomeScore = Int32.Parse(Math.Round(homeScore, 0).ToString()); var intAwayScore = Int32.Parse(Math.Round(awayScore, 0).ToString()); var res = new NFLResult(game.HomeTeam, intHomeScore, game.AwayTeam, intAwayScore); if (StorePrediction) { StorePredictedResult(game, res); } //Utility.Announce( string.Format( "PredictGame: Result predicted - {0}", res.LogResult() ) ); return(res); }
public NFLGame(string weekIn, DateTime dateIn, string homeCodeIn, string awayCodeIn, int homeScoreIn, int awayScoreIn, decimal spreadIn, decimal totalIn, string season, string gameCode) { // constructor //RosterLib.Utility.Announce( string.Format( " Constructing game in week {0} {1} @ {2}", weekIn, awayCodeIn, homeCodeIn ) ); YahooList = new List<YahooOutput>(); GridStatsList = new List<GridStatsOutput>(); Season = season; HomeScore = homeScoreIn; AwayScore = awayScoreIn; Spread = spreadIn; Total = totalIn; Week = weekIn; GameDate = dateIn; GameCode = gameCode; HomeTeam = homeCodeIn; AwayTeam = awayCodeIn; Result = new NFLResult(homeCodeIn, homeScoreIn, awayCodeIn, awayScoreIn); }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { var result = new NFLResult {AwayTeam = game.AwayTeam, HomeTeam = game.HomeTeam}; var homeTeam = game.HomeNflTeam; var awayTeam = game.AwayNflTeam; var nHomeOff = Utility.OffRating(homeTeam, predictionDate); var nAwayOff = Utility.OffRating(awayTeam, predictionDate); var nHomeDef = Utility.DefRating(homeTeam, predictionDate); var nAwayDef = Utility.DefRating(awayTeam, predictionDate); result.HomeScore = (nHomeOff + nAwayDef) - 20; result.AwayScore = (nAwayOff + nHomeDef) - 20; persistor.StorePrediction("Miller", game, result); if (AuditTrail) Utility.Announce(string.Format("{0}-{1}:{2}", game.GameCodeOut(), game.GameCode, result.LogResult())); return result; }
private static void AuditIt(NFLGame game, NFLResult res, int homeRating, int awayRating) { const string debugTeamCode = "SF"; var debugTeamRank = "(0-0)"; var strVenue = "unknown"; var oppTeamCode = "YY"; var oppRank = "(0-0)"; const string rankFormat = "({0})"; var bAudit = false; if (game.HomeTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Home"; oppTeamCode = game.AwayTeam; oppRank = string.Format(rankFormat, awayRating); debugTeamRank = string.Format(rankFormat, homeRating); } if (game.AwayTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Away"; oppTeamCode = game.HomeTeam; oppRank = string.Format(rankFormat, homeRating); debugTeamRank = string.Format(rankFormat, awayRating); } if (!bAudit) { return; } #if DEBUG Utility.Announce(string.Format(" {5} Debug Team {0} {1}, is {2} vs {3} {4}", debugTeamCode, debugTeamRank, strVenue, oppTeamCode, oppRank, game.GameCodeOut())); Utility.Announce(res.LogResult()); // verbosity #endif }
public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { const int avgScore = 21; var homeRating = RatingsService.GetNibbleRatingFor(game.HomeNflTeam, predictionDate); var awayRating = RatingsService.GetNibbleRatingFor(game.AwayNflTeam, predictionDate); var homeOff = homeRating.Offence; var homeDef = homeRating.Defence; var awayOff = awayRating.Offence; var awayDef = awayRating.Defence; var homeScore = avgScore + ((homeOff + awayDef) / 2) + 3; // 3pts home field advantage var awayScore = avgScore + ((awayOff + homeDef) / 2); homeScore = Utility.PickAScore(homeScore); awayScore = Utility.PickAScore(awayScore); if (homeScore == awayScore) { homeScore++; // no ties } var res = new NFLResult(game.HomeTeam, homeScore, game.AwayTeam, awayScore); //TODO: Nibble predictor does not predict Tdp or Tdr if (AuditTrail) { AuditPrediction(game, awayDef, awayOff, homeOff, res, homeDef); if (StorePrediction) { StorePredictedResult(game, res); } } return(res); }
/// <summary> /// Game key is YYYY:0W-X /// </summary> /// <param name="gameKey"></param> public NFLGame(string gameKey) { if (gameKey.Equals( "BYE" )) { Season = "XXXX"; Week = "XX"; GameCode = "X"; } else { YahooList = new List<YahooOutput>(); GridStatsList = new List<GridStatsOutput>(); if (gameKey.Length < 4) throw new Exception("Invalid Game Key :" + gameKey); Season = gameKey.Substring( 0, 4 ); Week = gameKey.Substring( 5, 2 ); GameCode = gameKey.Substring( 8, 1 ); var ds = Utility.TflWs.GameFor( Season, Week, GameCode ); var dr = ds.Tables[ 0 ].Rows[ 0 ]; LoadGameFromDr( dr ); if (Played()) Result = new NFLResult( HomeTeam, HomeScore, AwayTeam, AwayScore ); } }
public void CalculateSpreadResult() { if ( Spread == 0 ) { // OTB, give it to the home team 21-20 HomeScore = 21; AwayScore = 20; } else { // what is the bookies tip var winningScore = 0.0M; var losingScore = 0.0M; if ( ( Total > 0 ) ) { var splitScore = Total - Math.Abs( Spread ); losingScore = Math.Round(splitScore / 2, MidpointRounding.AwayFromZero); winningScore = Math.Round( Total - losingScore, MidpointRounding.AwayFromZero ); } if ( ( winningScore - losingScore ) < Math.Abs( Spread ) ) winningScore++; if ( Spread > 0 ) { HomeScore = ( int ) winningScore; AwayScore = ( int ) losingScore; } else { HomeScore = ( int ) losingScore; AwayScore = ( int ) winningScore; } } BookieTip = new NFLResult(HomeTeam, HomeScore, AwayTeam, AwayScore); }
private void LoadGameFromDr(DataRow dr) { if (dr == null) return; Id = dr["id"].ToString(); Season = dr["SEASON"].ToString(); Week = dr["WEEK"].ToString(); Spread = Decimal.Parse(dr["SPREAD"].ToString()); Total = Decimal.Parse(dr["TOTAL"].ToString()); GameDate = DateTime.Parse(dr["GAMEDATE"].ToString()); GameCode = dr["GAMENO"].ToString(); HomeTeam = dr["HOMETEAM"].ToString(); AwayTeam = dr["AWAYTEAM"].ToString(); HomeScore = Int32.Parse(dr["HOMESCORE"].ToString()); AwayScore = Int32.Parse(dr["AWAYSCORE"].ToString()); Hour = dr["GAMEHOUR"].ToString(); IsOnTv = Boolean.Parse(dr["GAMELIVE"].ToString()); MyTip = dr["MYTIP"].ToString(); ProjectedAwayFg = Int32.Parse(dr["AWAY_FG"].ToString()); ProjectedAwayTdp = Int32.Parse(dr["AWAY_TDP"].ToString()); ProjectedAwayTdr = Int32.Parse(dr["AWAY_TDR"].ToString()); ProjectedHomeFg = Int32.Parse(dr["HOME_FG"].ToString()); ProjectedHomeTdp = Int32.Parse(dr["HOME_TDP"].ToString()); ProjectedHomeTdr = Int32.Parse(dr["HOME_TDR"].ToString()); AwayFg = Int32.Parse(dr["AWAY_FG"].ToString()); AwayTDp = Int32.Parse(dr["AWAY_TDP"].ToString()); AwayTDr = Int32.Parse(dr["AWAY_TDR"].ToString()); AwayTDd = Int32.Parse(dr["AWAY_TDD"].ToString()); AwayTDd = Int32.Parse(dr["AWAY_TDS"].ToString()); HomeFg = Int32.Parse(dr["HOME_FG"].ToString()); HomeTDp = Int32.Parse(dr["HOME_TDP"].ToString()); HomeTDr = Int32.Parse(dr["HOME_TDR"].ToString()); HomeTDd = Int32.Parse(dr["HOME_TDD"].ToString()); HomeTDs = Int32.Parse(dr["HOME_TDS"].ToString()); HomeTeamName = Masters.Tm.TeamFor(HomeTeam, Season); AwayTeamName = Masters.Tm.TeamFor(AwayTeam, Season); GetHomeTeam(); GetAwayTeam(); Result = new NFLResult(HomeTeam, HomeScore, AwayTeam, AwayScore); }
internal string EvaluatePrediction(NFLResult predictedResult) { if (Played()) return predictedResult.WinningTeam().Equals(Result.WinningTeam()) ? "SU:WIN" : "SU:LOSS"; return "Not Played"; }
public void StoreResult(NFLResult res) { Utility.TflWs.StoreResult(Season, Week, GameCode, res.AwayScore, res.HomeScore, res.HomeTDp, res.AwayTDp, res.HomeTDr, res.AwayTDr, res.HomeFg, res.AwayFg, res.AwayTDd, res.HomeTDd, res.AwayTDs, res.HomeTDs); }
public void RefreshTotals() { #if DEBUG Utility.Announce(string.Format("Refreshing TD totals {0}", GameCodeOut())); #endif var scores = Utility.TflWs.ScoresDs(Season, Week, GameCode); var nHomeTDp = 0; var nAwayTDp = 0; var nHomeTDr = 0; var nAwayTDr = 0; var nHomeFg = 0; var nAwayFg = 0; var nHomeTDd = 0; var nAwayTDd = 0; var nHomeTDs = 0; var nAwayTDs = 0; foreach (DataRow dr in scores.Tables[0].Rows) { var isHome = IsHome(dr["TEAM"].ToString()); var scoreType = dr["SCORE"].ToString(); switch (scoreType) { case Constants.K_SCORE_TD_PASS: if (isHome) nHomeTDp++; else nAwayTDp++; break; case Constants.K_SCORE_TD_RUN: if (isHome) nHomeTDr++; else nAwayTDr++; break; case Constants.K_SCORE_INTERCEPT_RETURN: if (isHome) nHomeTDd++; else nAwayTDd++; break; case Constants.K_SCORE_FUMBLE_RETURN: if (isHome) nHomeTDd++; else nAwayTDd++; break; case Constants.K_SCORE_KICK_RETURN: if (isHome) nHomeTDs++; else nAwayTDs++; break; case Constants.K_SCORE_PUNT_RETURN: if (isHome) nHomeTDs++; else nAwayTDs++; break; case Constants.K_SCORE_FIELD_GOAL: if (isHome) nHomeFg++; else nAwayFg++; break; } } var res = new NFLResult(HomeTeam, HomeScore, AwayTeam, AwayScore) { HomeTDp = nHomeTDp, HomeTDr = nHomeTDr, HomeTDd = nHomeTDd, HomeTDs = nHomeTDs, AwayTDr = nAwayTDr, AwayTDp = nAwayTDp, AwayTDd = nAwayTDd, AwayTDs = nAwayTDs, HomeFg = nHomeFg, AwayFg = nAwayFg }; StoreResult(res); }
private static int AnnounceResult( NFLGame game, NFLResult result, int suWins, ref int suLosses, ref int atsWins, ref int atsTies, ref int atsLosses ) { Utility.Announce( game.ScoreOut() ); var su = game.EvaluatePrediction( result ); Utility.Announce( su ); if (su.IndexOf( "WIN" ) > -1) suWins++; else suLosses++; var ats = game.EvaluatePredictionAts( result, game.Spread ); if (ats.IndexOf( "WIN" ) > -1) atsWins++; else if (ats.IndexOf( "PUSH" ) > -1) atsTies++; else atsLosses++; Utility.Announce( ats ); return suWins; }
public string EvaluatePredictionAts(NFLResult predictedResult, decimal spread) { if (Played()) { var predictedMargin = (Decimal)predictedResult.Margin(); if (predictedMargin.Equals(spread)) return "ATS:PUSH"; var selection = predictedResult.WinningTeamAts(spread); Utility.Announce(string.Format("Prediction chooses {0} to win when spread is {1}", selection, spread)); var actualWinner = Result.WinningTeamAts(spread); if (actualWinner.Equals("TIE")) return "ATS:PUSH"; return selection.Equals(actualWinner) ? "ATS:WIN" : "ATS:LOSS"; } return "Not Played"; }
private static void AuditPrediction(NFLGame game, int awayDef, int awayOff, int homeOff, NFLResult res, int homeDef) { const string debugTeamCode = "GB"; var debugTeamRank = "(0-0)"; var strVenue = "unknown"; var oppTeamCode = "YY"; var oppRank = "(0-0)"; const string rankFormat = "({0}.{1}={2})"; var bAudit = false; if (game.HomeTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Home"; oppTeamCode = game.AwayTeam; oppRank = string.Format(rankFormat, awayOff, awayDef, Rating(awayOff, awayDef)); debugTeamRank = string.Format(rankFormat, homeOff, homeDef, Rating(homeOff, homeDef)); } if (game.AwayTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Away"; oppTeamCode = game.HomeTeam; oppRank = string.Format(rankFormat, homeOff, homeDef, Rating(homeOff, homeDef)); debugTeamRank = string.Format(rankFormat, awayOff, awayDef, Rating(awayOff, awayDef)); } if (!bAudit) { return; } Utility.Announce(string.Format(" {5} Debug Team {0} {1}, is {2} vs {3} {4}", debugTeamCode, debugTeamRank, strVenue, oppTeamCode, oppRank, game.GameCodeOut())); Utility.Announce(res.LogResult()); }
private static void AuditPrediction(NFLGame game, int awayDef, int awayOff, int homeOff, NFLResult res, int homeDef) { const string debugTeamCode = "GB"; var debugTeamRank = "(0-0)"; var strVenue = "unknown"; var oppTeamCode = "YY"; var oppRank = "(0-0)"; const string rankFormat = "({0}.{1}={2})"; var bAudit = false; if (game.HomeTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Home"; oppTeamCode = game.AwayTeam; oppRank = string.Format(rankFormat, awayOff, awayDef, Rating(awayOff, awayDef)); debugTeamRank = string.Format(rankFormat, homeOff, homeDef, Rating(homeOff, homeDef)); } if (game.AwayTeam.Equals(debugTeamCode)) { bAudit = true; strVenue = "Away"; oppTeamCode = game.HomeTeam; oppRank = string.Format(rankFormat, homeOff, homeDef, Rating(homeOff, homeDef)); debugTeamRank = string.Format(rankFormat, awayOff, awayDef, Rating(awayOff, awayDef)); } if (!bAudit) return; Utility.Announce(string.Format(" {5} Debug Team {0} {1}, is {2} vs {3} {4}", debugTeamCode, debugTeamRank, strVenue, oppTeamCode, oppRank, game.GameCodeOut())); Utility.Announce(res.LogResult()); }
private void StorePredictedResult( NFLGame game, NFLResult nflResult ) { PredictionStorer.StorePrediction( "hillin", game, nflResult ); }
public void StorePrediction(string method, NFLGame game, NFLResult result) { }
private static void AuditIt( NFLGame game, NFLResult res, int homeRating, int awayRating ) { const string debugTeamCode = "SF"; var debugTeamRank = "(0-0)"; #if DEBUG var strVenue = "unknown"; #endif var oppTeamCode = "YY"; var oppRank = "(0-0)"; const string rankFormat = "({0})"; var bAudit = false; if (game.HomeTeam.Equals(debugTeamCode)) { bAudit = true; #if DEBUG strVenue = "Home"; #endif oppTeamCode = game.AwayTeam; oppRank = string.Format(rankFormat, awayRating ); debugTeamRank = string.Format(rankFormat, homeRating ); } if (game.AwayTeam.Equals(debugTeamCode)) { bAudit = true; #if DEBUG strVenue = "Away"; #endif oppTeamCode = game.HomeTeam; oppRank = string.Format(rankFormat, homeRating ); debugTeamRank = string.Format( rankFormat, awayRating ); } if (!bAudit) return; #if DEBUG Utility.Announce(string.Format(" {5} Debug Team {0} {1}, is {2} vs {3} {4}", debugTeamCode, debugTeamRank, strVenue, oppTeamCode, oppRank, game.GameCodeOut())); Utility.Announce(res.LogResult()); // verbosity #endif }