public NFLResult PredictGame(NFLGame game, IStorePredictions persistor, DateTime predictionDate) { var res = game.Played() ? new NFLResult( game.HomeTeam, game.HomeScore, game.AwayTeam, game.AwayScore ) : new NFLResult( game.HomeTeam, 21, game.AwayTeam, 17 ); return res; }
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 RateGame( NFLGame g ) { if ( g.Played() ) { if ( AuditIt ) Utility.Announce( string.Format( "Rating game {0}", g.ScoreOut() ) ); // workout the Average Score //AverageScore = Season.AverageScoreAfterWeek( g.WeekNo ); const int averageScore = 21; // this is pretty much fixed var adjustment = new NibbleGameRating( 0, 0, 0, 0 ); var ff = FudgeFactor(); adjustment.HomeOff = ( MaximumScore( g.HomeScore ) - averageScore ) / ff; adjustment.HomeDef = ( MaximumScore( g.AwayScore ) - averageScore ) / ff; adjustment.AwayOff = ( MaximumScore( g.AwayScore ) - averageScore ) / ff; adjustment.AwayDef = ( MaximumScore( g.HomeScore ) - averageScore ) / ff; if ( AuditIt ) { Utility.Announce(string.Format(" Actual score {0} {1:00} v {2} {3:00}", g.HomeTeam, g.HomeScore, g.AwayTeam, g.AwayScore)); Utility.Announce(string.Format(" Adjustments H {0} {1} - {2}", g.HomeTeam, adjustment.HomeOff, adjustment.HomeDef)); Utility.Announce(string.Format(" Adjustments A {0} {1} - {2}", g.AwayTeam, adjustment.AwayOff, adjustment.AwayDef)); } AdjustRatings( adjustment, g.HomeTeam, g.AwayTeam); } }
public Decimal RatePlayer( NFLPlayer plyr, NFLWeek week ) { // Points for Scores and points for stats if ( week.WeekNo.Equals( 0 ) ) return 0; if ( plyr.TeamCode == null ) { Console.WriteLine("{0} has a null teamcode", plyr); return 0; } GameKey = Week.GameCodeFor( plyr.TeamCode ); if (string.IsNullOrEmpty(GameKey)) return 0; Game = new NFLGame(GameKey); WeekHasPassed = Game.Played(); Week = week; // set the global week, other wise u will get the same week all the time plyr.Points = 0; // start from scratch #region Passing // 4 pts for a Tdp var tdpPts = PointsFor( plyr, 4, Constants.K_SCORE_TD_PASS, id: "2" ); plyr.Points += tdpPts; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for Tdp", plyr.PlayerName, tdpPts ) ); #endif // 2 pts for a PAT pass var ptsForPATpasses = PointsFor( plyr, 2, Constants.K_SCORE_PAT_PASS, id: "2" ); plyr.Points += ptsForPATpasses; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for PAT passes", plyr.PlayerName, ptsForPATpasses ) ); #endif // 1 pt / 25 YDp var ptsForYDp = PointsForStats( plyr: plyr, increment: 1, forStatType: Constants.K_STATCODE_PASSING_YARDS, divisor: 25.0M ); plyr.Points += ptsForYDp; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for {2} YDp", plyr.PlayerName, ptsForYDp, plyr.ProjectedYDp )); #endif // -2 pts for an Interception var ptsForInts = PointsForStats( plyr: plyr, increment: -1, forStatType: Constants.K_STATCODE_INTERCEPTIONS_THROWN, divisor: 1.0M ); plyr.Points += ptsForInts; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for Interceptions", plyr.PlayerName, ptsForInts ) ); #endif #endregion Passing #region Catching // 6 pts for a TD catch var ptsForTDcatches = PointsFor( plyr, 6, Constants.K_SCORE_TD_PASS, id: "1" ); plyr.Points += ptsForTDcatches; #if DEBUG if (plyr.PlayerCode.Equals("BRATCA01")) Utility.Announce( string.Format( "{0} has {1} points for TD catches", plyr.PlayerName, ptsForTDcatches ) ); #endif // 2 points for a 2 point conversion var ptsForPATcatches = PointsFor( plyr, 2, Constants.K_SCORE_PAT_PASS, id: "1" ); plyr.Points += ptsForPATcatches; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for PAT catches", plyr.PlayerName, ptsForPATcatches ) ); #endif // 1 pt / 10 yds var ptsForYDs = PointsForStats( plyr: plyr, increment: 1, forStatType: Constants.K_STATCODE_RECEPTION_YARDS, divisor: 10.0M ); plyr.Points += ptsForYDs; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for YDc", plyr.PlayerName, ptsForYDs ) ); #endif #endregion Catching #region Running // 6 points for TD run var ptsForTDruns = PointsFor( plyr, 6, Constants.K_SCORE_TD_RUN, id: "1" ); plyr.Points += ptsForTDruns; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for TD runs", plyr.PlayerName, ptsForTDruns ) ); #endif var ptsForPaTruns = PointsFor( plyr, 2, Constants.K_SCORE_PAT_RUN, id: "1" ); plyr.Points += ptsForPaTruns; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for PAT runs", plyr.PlayerName, ptsForPaTruns ) ); #endif // 1 pt / 10 yds var ptsForYDr = PointsForStats( plyr: plyr, increment: 1, forStatType: Constants.K_STATCODE_RUSHING_YARDS, divisor: 10.0M ); plyr.Points += ptsForYDr; #if DEBUG Utility.Announce( string.Format( "{0} has {1} points for YDr", plyr.PlayerName, ptsForYDr ) ); #endif #endregion Running #region Kicking plyr.Points += PointsFor( plyr, 3, Constants.K_SCORE_FIELD_GOAL, "1" ); plyr.Points += PointsFor( plyr, 1, Constants.K_SCORE_PAT, "1" ); #endregion Kicking Logger.Trace( string.Format( "{0} has {1} in week {2}:{3}", plyr.PlayerName, plyr.Points, week.Season, week.Week ) ); // side effect - store metrics if (!WeekHasPassed) return plyr.Points; if ( plyr.GameMetrics.ContainsKey( GameKey ) ) PgmDao.SaveActuals( plyr.GameMetrics[ GameKey ] ); else { #if DEBUG Utility.Announce( string.Format( "{0} not found in player Game Metrics", GameKey ) ); #endif } return plyr.Points; }
public NFLResult PredictGame( NFLGame game, IStorePredictions persistor, DateTime predictionDate ) { if ( TakeActuals ) if ( game.Played() ) return game.Result; const int homeRating = 0; const int awayRating = 0; 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 homeMetrics = CalculateGameMetrics( true, game, predictionDate ); var awayMetrics = CalculateGameMetrics( false, game, predictionDate ); var homeScore = homeMetrics.Score; var awayScore = awayMetrics.Score; if (homeScore == awayScore) homeScore++; // no ties game.Result = new NFLResult( game.HomeTeam, homeScore, game.AwayTeam, awayScore ) { HomeTDp = _homeTDp, HomeTDr = _homeTDr, HomeFg = _homeFg, HomeTDd = _homeTDd, HomeTDs = _homeTDs, HomeYDp = homeMetrics.YDp, HomeYDr = homeMetrics.YDr, AwayTDr = _awayTDr, AwayTDp = _awayTDp, AwayTDs = awayMetrics.TDs, AwayTDd = awayMetrics.TDd, AwayYDp = awayMetrics.YDp, AwayYDr = awayMetrics.YDr, AwayFg = _awayFg }; if ( AuditTrail ) AuditIt( game, game.Result, homeRating, awayRating ); if ( StorePrediction ) StorePredictedResult( game, game.Result ); // pulled this out to its own job "GameProjectionReportsJob" //if ( WriteProjection ) // game.WriteProjection(); return game.Result; }
private void RateGame( NFLGame g ) { if ( g.Played() ) { Utility.Announce( string.Format( "Rating game {0}", g.GameName() ) ); // workout the Average Score //AverageScore = Season.AverageScoreAfterWeek( g.WeekNo ); AverageScore = 21; // this is pretty much fixed // workout adjustments to the previous ratings NibbleGameRating startingGameRating; if ( g.Week.Equals( "01" ) ) startingGameRating = new NibbleGameRating( 0, 0, 0, 0 ); else // Get previous rating startingGameRating = GetRating( g ); var projHome = (int) ( AverageScore + ( ( startingGameRating.HomeOff + startingGameRating.AwayDef )/2 ) ); projHome += 3; // home field advantage var projAway = (int) ( AverageScore + ( ( startingGameRating.AwayOff + startingGameRating.HomeDef )/2 ) ); var adjustment = new NibbleGameRating( 0, 0, 0, 0 ); var ff = FudgeFactor( g.Week ); adjustment.HomeOff = ( MaximumScore( g.HomeScore ) - projHome ) / ff; adjustment.HomeDef = ( MaximumScore( g.AwayScore ) - projAway ) / ff; adjustment.AwayOff = ( MaximumScore( g.AwayScore ) - projAway ) / ff; adjustment.AwayDef = ( MaximumScore( g.HomeScore ) - projHome ) / ff; Utility.Announce(string.Format(" Projected score {0} {1:00} v {2} {3:00}", g.HomeTeam, projHome, g.AwayTeam, projAway)); Utility.Announce(string.Format(" Actual score {0} {1:00} v {2} {3:00}", g.HomeTeam, g.HomeScore, g.AwayTeam, g.AwayScore)); Utility.Announce(string.Format(" Adjustments H {0} {1} - {2}", g.HomeTeam, adjustment.HomeOff, adjustment.HomeDef )); Utility.Announce(string.Format(" Adjustments A {0} {1} - {2}", g.AwayTeam, adjustment.AwayOff, adjustment.AwayDef)); AdjustRatings( startingGameRating, adjustment, g.HomeTeam, g.AwayTeam, g.Week ); } }
public TipResult CheckResultAts() { var game = new NFLGame( Utility.GameKey( Season, Week, GameCode ) ); Result = TipResult.None; var betOn = String.Empty; if ( game.Played() ) { if ( game.Spread < 0 ) { // Away team favoured if (PredictedSpread < game.Spread) betOn = game.AwayTeam; else if (PredictedSpread > game.Spread) betOn = game.HomeTeam; } else if ( game.Spread > 0 ) { // home team favoured if (PredictedSpread > game.Spread) betOn = game.HomeTeam; else if (PredictedSpread > game.Spread) betOn = game.AwayTeam; } } if ( ! string.IsNullOrEmpty( betOn ) ) { if (game.ResultvsSpread(betOn).Equals("Win")) Result = TipResult.Correct; else if (game.ResultvsSpread(betOn).Equals("Loss")) Result = TipResult.Incorrect; else Result = TipResult.Push; } return Result; }
public TipResult CheckResult() { var game = new NFLGame(Utility.GameKey(Season, Week, GameCode)); if (game.Played()) { Result = HomeWinTipped() ? (game.HomeWin() ? TipResult.Correct : TipResult.Incorrect) : (game.AwayWin() ? TipResult.Correct : TipResult.Incorrect); } else Result = TipResult.None; return Result; }