public Int32 PredictTDr(NFLPlayer plyr, string season, int week) { // Predict the number of FGs this player will kick int tDr = 0; // starters only if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RUNNINGBACK_CAT) && plyr.IsRusher() ) { if (plyr.CurrTeam.Ratings.Equals("CCCCCC")) plyr.CurrTeam.SetRecord(season, skipPostseason:false); // who are the opponents NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week); if (opponent != null) { if (opponent.Ratings.Equals("CCCCCC")) opponent.SetRecord(season, skipPostseason: false); // Incase not initialised // not on a bye tDr = 1; int diff = ConvertRating(plyr.CurrTeam.RoRating()) - ConvertRating(opponent.RdRating()); if (diff > 1) tDr += 1; if (diff > 3) tDr += 1; if (diff < -1) tDr -= 1; } // What is the Game NFLGame game = plyr.CurrTeam.GameFor(season, week); if (game != null) { if (game.IsHome(plyr.CurrTeam.TeamCode)) tDr += 1; if (game.IsBadWeather()) tDr -= 1; } } return tDr; }
public Int32 PredictYDc(NFLPlayer plyr, string season, int week) { int YDc = 0; // starters only if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RECEIVER_CAT)) { int gamesOppPlayed = 0; NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week); if (opponent != null) // not on a bye { // Workout Team YDc average int teamTotYDc = 0; int gamesPlayed = 0; plyr.CurrTeam.LoadGames(plyr.CurrTeam.TeamCode, season); foreach (NFLGame g in plyr.CurrTeam.GameList) { if (g.Played()) { g.TallyMetrics("Y"); teamTotYDc += g.IsHome(plyr.CurrTeam.TeamCode) ? g.HomeYDp : g.AwayYDp; gamesPlayed++; } } // work out the average that the oppenent gives up int teamTotYDcAllowed = 0; opponent.LoadGames(opponent.TeamCode, season); foreach (NFLGame g in opponent.GameList) { if (g.Played()) { g.TallyMetrics("Y"); teamTotYDcAllowed += g.IsHome(plyr.CurrTeam.TeamCode) ? g.AwayYDr : g.HomeYDr; // switch it around gamesOppPlayed++; } } Decimal predictedYDc; if ((gamesPlayed > 0) && (gamesOppPlayed > 0)) { // Average the averages predictedYDc = ((teamTotYDc / gamesPlayed) + (teamTotYDcAllowed / gamesOppPlayed)) / 2; } else { predictedYDc = 0.0M; } // find out how many carries the starter usually has // YDr is the proportion of the whole YDc = plyr.IsTe() ? Convert.ToInt32(predictedYDc * .2M) : Convert.ToInt32(predictedYDc * .4M); } } return(YDc); }
public PlayerLister( string catCode, bool faOnly, [Optional] string fantasyLeague, [Optional] bool startersOnly, [Optional] IKeepTheTime timekeeper ) { if (timekeeper != null) { TimeKeeper = timekeeper; } PrimariesOnly = true; ActivesOnly = true; FreeAgentsOnly = false; StartersOnly = startersOnly; PlayerList = new ArrayList(); Folder = string.Empty; var ds = Utility.TflWs.GetPlayers(catCode); var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { var p = new NFLPlayer(dr, fantasyLeague); var bAdd = !faOnly || p.IsFreeAgent(); if (ActivesOnly) { bAdd = bAdd && p.IsActive(); } if (StartersOnly) { bAdd = bAdd && p.IsStarter(); } if (PlayoffsOnly) { bAdd = bAdd && p.IsPlayoffBound(); } if (PrimariesOnly) { bAdd = bAdd && !p.IsItalic(); // dont want FB, TE or punters } if (OnesAndTwosOnly) { bAdd = bAdd && p.IsOneOrTwo(); } if (catCode.Equals("2")) // there is a lack of RBs { bAdd = bAdd && p.IsOneOrTwo(); } if (bAdd) { PlayerList.Add(p); } } WeeksToGoBack = Constants.K_WEEKS_IN_A_SEASON; // default }
public Int32 PredictYDr(NFLPlayer plyr, string season, int week) { int YDr = 0; // starters only if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RUNNINGBACK_CAT) && plyr.IsRusher()) { int gamesOppPlayed = 0; NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week); if (opponent != null) // not on a bye { // Workout Team YDr average int teamTotYDr = 0; int gamesPlayed = 0; plyr.CurrTeam.LoadGames(plyr.CurrTeam.TeamCode, season); foreach (NFLGame g in plyr.CurrTeam.GameList) { if (g.Played()) { g.TallyMetrics("Y"); teamTotYDr += g.IsHome(plyr.CurrTeam.TeamCode) ? g.HomeYDr : g.AwayYDr; gamesPlayed++; } } // work out the average that the oppenent gives up int teamTotYDrAllowed = 0; opponent.LoadGames(opponent.TeamCode, season); foreach (NFLGame g in opponent.GameList) { if (g.Played()) { g.TallyMetrics("Y"); teamTotYDrAllowed += g.IsHome(plyr.CurrTeam.TeamCode) ? g.AwayYDr : g.HomeYDr; // switch it around gamesOppPlayed++; } } Decimal predictedYDr; if ((gamesPlayed > 0) && (gamesOppPlayed > 0)) { // Average the averages predictedYDr = ((teamTotYDr / gamesPlayed) + (teamTotYDrAllowed / gamesOppPlayed)) / 2; } else predictedYDr = 0.0M; // find out how many carries the starter usually has // YDr is the proportion of the whole YDr = Convert.ToInt32(predictedYDr * .8M); } } return YDr; }
public Int32 PredictTDc(NFLPlayer plyr, string season, int week) { // Predict the number of FGs this player will kick int tdc = 0; // starters only if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RECEIVER_CAT)) { if (plyr.CurrTeam.Ratings.Equals("CCCCCC")) { plyr.CurrTeam.SetRecord(season); } // who are the opponents NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week); if (opponent != null) { if (opponent.Ratings.Equals("CCCCCC")) { opponent.SetRecord(season); // Incase not initialised } // not on a bye tdc = 1; int diff = ConvertRating(plyr.CurrTeam.PoRating()) - ConvertRating(opponent.PdRating()); if (diff > 0) { tdc += 1; } if (diff > 2) { tdc += 1; } if (diff < -2) { tdc -= 1; } } // What is the Game NFLGame game = plyr.CurrTeam.GameFor(season, week); if (game != null) { if (game.IsHome(plyr.CurrTeam.TeamCode)) { tdc += 1; } if (game.IsBadWeather()) { tdc -= 1; } } tdc = plyr.IsTe() ? Convert.ToInt32(tdc * .25M) : Convert.ToInt32(tdc * .5M); } return(tdc); }
public Int32 PredictTDr(NFLPlayer plyr, string season, int week) { // Predict the number of FGs this player will kick int tDr = 0; // starters only if (plyr.IsStarter() && (plyr.PlayerCat == RosterLib.Constants.K_RUNNINGBACK_CAT) && plyr.IsRusher()) { if (plyr.CurrTeam.Ratings.Equals("CCCCCC")) { plyr.CurrTeam.SetRecord(season, skipPostseason: false); } // who are the opponents NflTeam opponent = plyr.CurrTeam.OpponentFor(season, week); if (opponent != null) { if (opponent.Ratings.Equals("CCCCCC")) { opponent.SetRecord(season, skipPostseason: false); // Incase not initialised } // not on a bye tDr = 1; int diff = ConvertRating(plyr.CurrTeam.RoRating()) - ConvertRating(opponent.RdRating()); if (diff > 1) { tDr += 1; } if (diff > 3) { tDr += 1; } if (diff < -1) { tDr -= 1; } } // What is the Game NFLGame game = plyr.CurrTeam.GameFor(season, week); if (game != null) { if (game.IsHome(plyr.CurrTeam.TeamCode)) { tDr += 1; } if (game.IsBadWeather()) { tDr -= 1; } } } return(tDr); }
public void Load() { _ft = new FrequencyTable($@"{PlayerType} output week { wRange.startWeek.WeekKey( "-" ) } to { wRange.endWeek.WeekKey( "-" ) }" ); if (string.IsNullOrEmpty(SinglePlayer)) { // get players who appeared in this range var ds = Utility.TflWs.GetPlayersScoring( ScoreType, wRange.startWeek.Season, wRange.endWeek.Season, ScoreSlot); var dt = ds.Tables["score"]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { var player = new NFLPlayer(dr[string.Format("PLAYERID{0}", ScoreSlot)].ToString()); if (player.IsStarter()) { playerList.Add(player); Utility.Announce($@" Adding { player.PlayerNameShort,-15 } to the list of {PlayerType}" ); } } } } else { // single player var player = new NFLPlayer(SinglePlayer); playerList.Add(player); Utility.Announce(string.Format(" Adding {0,-15} to the list of {1}", player.PlayerNameShort, PlayerType)); } Utility.Announce($" Examining {playerList.Count:#0} players"); // do the counting, so get all the performances for foreach (NFLPlayer p in playerList) { var week = wRange.startWeek; while (wRange.endWeek.IsBefore(week)) { var amount = Scorer.RatePlayer(p, week); _ft.Add(amount); Utility.Announce(string.Format(" {0,-15} got {1,2} in {2}", p.PlayerNameShort, amount, week.WeekKey())); week = week.NextWeek(week); } } _ft.Calculate(); }
public void Load() { _ft = new FrequencyTable( string.Format("{2} output week {0} to {1}", wRange.startWeek.WeekKey("-"), wRange.endWeek.WeekKey("-"), PlayerType ) ); if (string.IsNullOrEmpty(SinglePlayer)) { // get players who appeared in this range var ds = Utility.TflWs.GetPlayersScoring( ScoreType, wRange.startWeek.Season, wRange.endWeek.Season, ScoreSlot); var dt = ds.Tables["score"]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { var player = new NFLPlayer(dr[string.Format("PLAYERID{0}", ScoreSlot)].ToString()); if (player.IsStarter()) { playerList.Add(player); Utility.Announce(string.Format(" Adding {0,-15} to the list of {1}", player.PlayerNameShort, PlayerType)); } } } } else { // single player var player = new NFLPlayer( SinglePlayer ); playerList.Add( player ); Utility.Announce(string.Format(" Adding {0,-15} to the list of {1}", player.PlayerNameShort, PlayerType)); } Utility.Announce(string.Format(" Examining {0:#0} players", playerList.Count)); // do the counting, so get all the performances for foreach (NFLPlayer p in playerList) { var week = wRange.startWeek; while ( wRange.endWeek.IsBefore( week ) ) { var amount = Scorer.RatePlayer( p, week ); _ft.Add( amount ); Utility.Announce( string.Format( " {0,-15} got {1,2} in {2}", p.PlayerNameShort, amount, week.WeekKey() ) ); week = week.NextWeek( week ); } } _ft.Calculate(); }
public List<string> Load(string teamCode) { TeamCode = teamCode; var ds = Utility.TflWs.GetTeamPlayers(teamCode, Constants.K_KICKER_CAT); var dt = ds.Tables["player"]; if (dt.Rows.Count == 0) return DumpUnit(); foreach (DataRow dr in dt.Rows) { var newPlayer = new NFLPlayer(dr["PLAYERID"].ToString()); Add(newPlayer); if (newPlayer.IsStarter()) PlaceKicker = newPlayer; } return DumpUnit(); }
public PlayerLister(string catCode, bool faOnly, [Optional] string fantasyLeague, [Optional] bool startersOnly ) { PrimariesOnly = true; ActivesOnly = true; FreeAgentsOnly = false; StartersOnly = startersOnly; PlayerList = new ArrayList(); var ds = Utility.TflWs.GetPlayers(catCode); var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { var p = new NFLPlayer(dr, fantasyLeague); var bAdd = !(faOnly) || p.IsFreeAgent(); if (ActivesOnly) { bAdd = (bAdd) && p.IsActive(); } if (StartersOnly) { bAdd = (bAdd) && p.IsStarter(); } if (PlayoffsOnly) { bAdd = (bAdd) && p.IsPlayoffBound(); } if (PrimariesOnly) { bAdd = (bAdd) && !p.IsItalic(); // dont want FB, TE or punters } if (OnesAndTwosOnly) { bAdd = (bAdd) && p.IsOneOrTwo(); } if (bAdd) { PlayerList.Add(p); } } WeeksToGoBack = Constants.K_WEEKS_IN_A_SEASON; // default }
public Int32 PredictFGs(NFLPlayer plyr, string season, int week) { // Predict the number of FGs this player will kick int fg = 0; // starters only if (plyr.IsStarter()) { // who does he play for NflTeam kickersTeam = plyr.CurrTeam; // who are the opponents NflTeam opponent = kickersTeam.OpponentFor(season, week); if (opponent != null) { // not on a bye fg += 1; if (opponent.IsGoodDefence()) { fg += 1; } } // What is the Game NFLGame game = kickersTeam.GameFor(season, week); if (game != null) { if (game.IsHome(kickersTeam.TeamCode)) { fg += 1; } if (game.IsDomeGame()) { fg += 1; } if (game.IsBadWeather()) { fg -= 1; } } } return(fg); }
public List <string> Load(string teamCode) { TeamCode = teamCode; var ds = Utility.TflWs.GetTeamPlayers(teamCode, Constants.K_KICKER_CAT); var dt = ds.Tables["player"]; if (dt.Rows.Count == 0) { return(DumpUnit()); } foreach (DataRow dr in dt.Rows) { var newPlayer = new NFLPlayer(dr["PLAYERID"].ToString()); Add(newPlayer); if (newPlayer.IsStarter()) { PlaceKicker = newPlayer; } } return(DumpUnit()); }
public PlayerLister(string catCode, bool faOnly, [Optional] string fantasyLeague, [Optional] bool startersOnly, [Optional] IKeepTheTime timekeeper ) { if (timekeeper != null) TimeKeeper = timekeeper; PrimariesOnly = true; ActivesOnly = true; FreeAgentsOnly = false; StartersOnly = startersOnly; PlayerList = new ArrayList(); Folder = string.Empty; var ds = Utility.TflWs.GetPlayers(catCode); var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { var p = new NFLPlayer(dr, fantasyLeague); var bAdd = !(faOnly) || p.IsFreeAgent(); if (ActivesOnly) bAdd = (bAdd) && p.IsActive(); if (StartersOnly) bAdd = (bAdd) && p.IsStarter(); if (PlayoffsOnly) bAdd = (bAdd) && p.IsPlayoffBound(); if (PrimariesOnly) bAdd = (bAdd) && !p.IsItalic(); // dont want FB, TE or punters if (OnesAndTwosOnly) bAdd = (bAdd) && p.IsOneOrTwo(); if (bAdd) PlayerList.Add(p); } WeeksToGoBack = Constants.K_WEEKS_IN_A_SEASON; // default }
public void Load() { var tc = new TeamCheckList(); PlayerList = new ArrayList(); var ds = Utility.TflWs.GetPlayers(CatCode, Position); var dt = ds.Tables[0]; #if DEBUG2 Utility.Announce($"{dt.Rows.Count} candidate players"); #endif foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Deleted) { continue; } var p = new NFLPlayer(dr, FantasyLeague); var bAdd = true; if (FreeAgentsOnly) { if (!string.IsNullOrEmpty(FantasyLeague)) // lookup owner { if (p.Owner.Equals("**")) { #if DEBUG2 Utility.Announce($@" Player {p.PlayerNameShort,-15} owned by { p.Owner } playoffs {(p.IsPlayoffBound() ? "Yes" : "No ")} starter { (p.IsStarter() ? "Yes" : "No ") }active {(p.IsActive() ? "Yes" : "No ")}" ); #endif } else { bAdd = false; } } } if (FantasyLeague == Constants.K_LEAGUE_Gridstats_NFL1) { bAdd = (bAdd) && p.IsPlayoffBound(); } bAdd = (bAdd) && p.IsActive(); if (StartersOnly) { bAdd = (bAdd) && p.IsStarter(); } if (bAdd) { #if DEBUG2 Utility.Announce($" Adding Player {p.PlayerNameShort,-15}"); #endif PlayerList.Add(p); if (Position != "WR") { tc.TickOff(p.TeamCode, Position); // there r 2 WRs } } } if (WeeksToGoBack == 0) { WeeksToGoBack = Constants.K_WEEKS_IN_A_SEASON; // default } #if DEBUG2 Utility.Announce($"PlayerLister.init {PlayerList.Count} {Position} players added to the list"); Utility.Announce($"Teams missing {Position} are {tc.TeamsLeft()}"); #endif }
public void Collect( string catCode, string sPos, string fantasyLeague, [Optional] string rookieYr) { DumpParameters(); DataSet ds; if (string.IsNullOrEmpty(sPos)) { ds = Utility.TflWs.GetPlayers(catCode); } else { ds = sPos.Equals("KR") ? Utility.TflWs.GetReturners() : Utility.TflWs.GetPlayers( catCode, sPos, role: OnesAndTwosOnly? null : "*", rookieYr: rookieYr); } var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Deleted) { continue; } var p = new NFLPlayer(dr, fantasyLeague); if (p.PlayerName == "Jonathan Taylor") { System.Console.WriteLine("Testplayer"); } var bAdd = true; if (FreeAgentsOnly) { bAdd = p.IsFreeAgent(); } if (PlayoffsOnly) { bAdd = bAdd && p.IsPlayoffBound(); } bAdd = bAdd && p.IsFantasyOffence(); bAdd = bAdd && p.IsActive(); if (StartersOnly) { bAdd = bAdd && p.IsStarter(); if (sPos.Equals("RB")) { bAdd = p.IsOneOrTwo(); } } if (OnesAndTwosOnly) { bAdd = bAdd && p.IsOneOrTwo(); } if (bAdd) { AnnounceAdd( catCode, sPos, p); PlayerList.Add(p); #if DEBUG2 // speed up things if (PlayerList.Count > 2) { break; } #endif if (StartersOnly) { if (sPos != null) { if (sPos != "WR") { Tc.TickOff(p.TeamCode, sPos); // there r 2 WRs } } } } else { AnnounceSkip( catCode, sPos, p); } } AnnounceTotal(sPos); }
public void Collect(string catCode, string sPos, string fantasyLeague) { Clear(); DataSet ds; if (string.IsNullOrEmpty(sPos)) { ds = Utility.TflWs.GetPlayers(catCode); } else { ds = sPos.Equals("KR") ? Utility.TflWs.GetReturners() : Utility.TflWs.GetPlayers(catCode, sPos); } var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { if (dr.RowState != DataRowState.Deleted) { var p = new NFLPlayer(dr, fantasyLeague); var bAdd = true; if (FreeAgentsOnly) { bAdd = p.IsFreeAgent(); } if (PlayoffsOnly) { bAdd = (bAdd) && p.IsPlayoffBound(); } bAdd = (bAdd) && p.IsFantasyOffence(); bAdd = (bAdd) && p.IsActive(); if (StartersOnly) { bAdd = (bAdd) && p.IsStarter(); } if (OnesAndTwosOnly) { bAdd = (bAdd) && p.IsOneOrTwo(); } if (bAdd) { AnnounceAdd(catCode, sPos, p); PlayerList.Add(p); if (StartersOnly) { if (sPos != null) { if (sPos != "WR") { Tc.TickOff(p.TeamCode, sPos); // there r 2 WRs } } } } } } AnnounceTotal(sPos); }
public void Load() { var tc = new TeamCheckList(); PlayerList = new ArrayList(); var ds = Utility.TflWs.GetPlayers(CatCode, Position); var dt = ds.Tables[0]; #if DEBUG Utility.Announce(string.Format("{0} candidate players", dt.Rows.Count)); #endif foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Deleted) continue; var p = new NFLPlayer(dr, FantasyLeague); var bAdd = true; if (FreeAgentsOnly) { if (!string.IsNullOrEmpty(FantasyLeague)) // lookup owner { if (p.Owner.Equals("**")) { #if DEBUG Utility.Announce(string.Format(" Player {0,-15} owned by {1} playoffs {2} starter {3} active {4}", p.PlayerNameShort, p.Owner, (p.IsPlayoffBound() ? "Yes" : "No "), (p.IsStarter() ? "Yes" : "No "), (p.IsActive() ? "Yes" : "No "))); #endif } else bAdd = false; } } if (FantasyLeague == Constants.K_LEAGUE_Gridstats_NFL1) bAdd = (bAdd) && p.IsPlayoffBound(); bAdd = (bAdd) && p.IsActive(); if (StartersOnly) bAdd = (bAdd) && p.IsStarter(); if (bAdd) { #if DEBUG Utility.Announce(string.Format(" Adding Player {0,-15}", p.PlayerNameShort)); #endif PlayerList.Add(p); if (Position != "WR") tc.TickOff(p.TeamCode, Position); // there r 2 WRs } } if ( WeeksToGoBack == 0 ) WeeksToGoBack = Constants.K_WEEKS_IN_A_SEASON; // default #if DEBUG Utility.Announce(string.Format("PlayerLister.init {0} {1} players added to the list", PlayerList.Count, Position)); Utility.Announce(string.Format("Teams missing {1} are {0}", tc.TeamsLeft(), Position)); #endif }
public void Collect( string catCode, string sPos, string fantasyLeague, [Optional] string rookieYr ) { DumpParameters(); DataSet ds; if (string.IsNullOrEmpty(sPos)) ds = Utility.TflWs.GetPlayers(catCode); else ds = sPos.Equals("KR") ? Utility.TflWs.GetReturners() : Utility.TflWs.GetPlayers( catCode, sPos, role:OnesAndTwosOnly? null : "*", rookieYr:rookieYr); var dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Deleted) continue; var p = new NFLPlayer(dr, fantasyLeague); var bAdd = true; if (FreeAgentsOnly) bAdd = p.IsFreeAgent(); if (PlayoffsOnly) bAdd = (bAdd) && p.IsPlayoffBound(); bAdd = (bAdd) && p.IsFantasyOffence(); bAdd = (bAdd) && p.IsActive(); if (StartersOnly) bAdd = (bAdd) && p.IsStarter(); if (OnesAndTwosOnly) bAdd = (bAdd) && p.IsOneOrTwo(); if (bAdd) { AnnounceAdd(catCode, sPos, p); PlayerList.Add(p); #if DEBUG2 // speed up things if (PlayerList.Count > 2) break; #endif if (StartersOnly) { if (sPos != null) if (sPos != "WR") Tc.TickOff(p.TeamCode, sPos); // there r 2 WRs } } } AnnounceTotal(sPos); }