private void StrengthOfSchedule(List <CTeam> ties) { /* ----------------------------------------------------------------------------------- * Combined record of all opponents. * If you play a team twice, does it count twice. I say yes. * ----------------------------------------------------------------------------------*/ var msg = new StringBuilder("Str. of schedule: "); foreach (var t in ties) { Record rec = default(Record); foreach (var g in t.teamSchedule) { CTeam opp = g.Opp(t); rec += opp.simRec.league; //Do not check if t was winner,just accumulate opp's rec. } t.Metric += 's' + rec.spct; if (detailMode) { msg.Append(t.teamTag + ":" + rec.wltString + " "); } } if (detailMode) { tieBreakerSummary.AppendLine(" " + msg.ToString()); } }
public /*Constructor*/ CGame(CTeam vis, CTeam home, ESite site) { // ----------------------------------------------------------------- // Constructor: this.TeamH = home; this.TeamV = vis; this.Site = site; this.Spread = null; // PlayGame() will use power ratings ComputeHomeProb(); }
public CTeam Opp(CTeam t) { // ------------------------------------------------------------- if (t == this.TeamH) { return(this.TeamV); } if (t == this.TeamV) { return(this.TeamH); } return(null); }
public bool Involves(CTeam t) { // ------------------------------------------------------------- return(this.TeamH == t || this.TeamV == t); }
public void BumpRecs( CTeam winner, CTeam loser, bool tie, EMode mode) { // --------------------------------------------------------------- bool isDiv = TeamV.divName == TeamH.divName; bool isConf = TeamV.confName == TeamH.confName; if (!tie) { switch (mode) { case EMode.Real: winner.realRec.league.w++; loser.realRec.league.l++; if (isDiv) { winner.realRec.div.w++; loser.realRec.div.l++; } if (isConf) { winner.realRec.conf.w++; loser.realRec.conf.l++; } break; case EMode.Sim: winner.simRec.league.w++; loser.simRec.league.l++; if (isDiv) { winner.simRec.div.w++; loser.simRec.div.l++; } if (isConf) { winner.simRec.conf.w++; loser.simRec.conf.l++; } break; } } else //tie { switch (mode) { case EMode.Real: TeamV.realRec.league.t++; TeamH.realRec.league.t++; if (isDiv) { TeamV.realRec.div.t++; TeamH.realRec.div.t++; } if (isConf) { TeamV.realRec.conf.t++; TeamH.realRec.conf.t++; } break; case EMode.Sim: TeamV.simRec.league.t++; TeamH.simRec.league.t++; if (isDiv) { TeamV.simRec.div.t++; TeamH.simRec.div.t++; } if (isConf) { TeamV.simRec.conf.t++; TeamH.simRec.conf.t++; } break; } } }
public void PlayGame(bool noTies = false) { /* ----------------------------------------------- * This sets the following: * Winner, Losr, WasTie, Result (EResult) * nTies=true is for post-season * ----------------------------------------------- */ // First, check if the game is overriden... (-bc 1807.01) switch (this.Override) { case EResult.NotPlayed: // This means not overriden, take no action here. break; case EResult.HomeWin: Winner = TeamH; Loser = TeamV; WasTie = false; Result = EResult.HomeWin; //Debug.WriteLine(WeekNo.ToString() + " Override: " + TeamH.teamTag + " / " + TeamV.teamTag); return; case EResult.VisWin: Winner = TeamV; Loser = TeamH; WasTie = false; Result = EResult.VisWin; //Debug.WriteLine(WeekNo.ToString() + " Override: " + TeamV.teamTag + " / " + TeamH.teamTag); return; case EResult.Tie: // Currently app does not allow override as tie, but maybe future... Winner = null; Loser = null; WasTie = true; Result = EResult.Tie; //Debug.WriteLine(WeekNo.ToString() + " Override: " + TeamV.teamTag + " ties " + TeamH.teamTag); return; } // Game is not overriden, so roll the dice... double tieProb = (noTies ? 0.0 : 0.01); double r = CSeason.rn.NextDouble(); //Roll the dice... if (r < tieProb) { // Tie game... Winner = null; Loser = null; WasTie = true; //BumpRecs(TeamH, TeamV, true, EMode.Sim); Result = EResult.Tie; //Debug.WriteLine(WeekNo.ToString() + " Simulated: " + TeamV.teamTag + " ties " + TeamH.teamTag); } else if (r < HomeProb + (1.0 - HomeProb) * tieProb) //tieProb + prob*(1- tieProb)) // Home team wins... { Winner = TeamH; Loser = TeamV; WasTie = false; //BumpRecs(TeamH, TeamV, false, EMode.Sim); Result = EResult.HomeWin; //Debug.WriteLine(WeekNo.ToString() + " Simulated: " + TeamH.teamTag + " / " + TeamV.teamTag); } else { // Vis team wins... Winner = TeamV; Loser = TeamH; WasTie = false; //BumpRecs(TeamV, TeamH, false, EMode.Sim); Result = EResult.VisWin; //Debug.WriteLine(WeekNo.ToString() + " Simulated: " + TeamV.teamTag + " / " + TeamH.teamTag); } }
public /*constructor*/ CGame(string[] arec, int i) { // -------------------------------------------------- // Constructor: int wk = int.Parse(arec[0]); string tagV = arec[1]; string tagH = arec[2]; char res = arec[3][0]; int scoreV = res == 'P' ? int.Parse(arec[4]) : 0; int scoreH = res == 'P' ? int.Parse(arec[5]) : 0; ESite site = arec[3].Length > 1 && arec[3][1] == '*' ? ESite.Nuetral : ESite.Home; double?spread; if (res == 'N' && arec.Length > 4) { spread = double.Parse(arec[4]); } else { spread = null; } WeekNo = wk; GameNumber = i; TeamIdV = CTeam.teamIndexes[tagV]; TeamIdH = CTeam.teamIndexes[tagH]; ScoreV = scoreV; ScoreH = scoreH; Site = site; Spread = spread; TeamV = CSeason.Teams[TeamIdV]; TeamH = CSeason.Teams[TeamIdH]; switch (res) { case 'P': if (scoreV > scoreH) { Result = EResult.VisWin; } else if (scoreV < scoreH) { Result = EResult.HomeWin; } else { Result = EResult.Tie; } OrigResult = Result; switch (Result) { case EResult.HomeWin: BumpRecs(TeamH, TeamV, false, EMode.Real); Winner = TeamH; Loser = TeamV; WasTie = false; break; case EResult.VisWin: BumpRecs(TeamV, TeamH, false, EMode.Real); Winner = TeamV; Loser = TeamH; WasTie = false; break; case EResult.Tie: BumpRecs(TeamV, TeamH, true, EMode.Real); Winner = null; Loser = null; WasTie = true; break; } break; case 'N': Result = EResult.NotPlayed; OrigResult = EResult.NotPlayed; ComputeHomeProb(); break; } }
private void GamesVsCommonOpponents(List <CTeam> ties) { /* ----------------------------------------------------------------------------------- * Found this on Reddit... I think it's correct. The 4-minimum referes to the * number of common opps, not the number of games, which can differ... * * It's based on winning percentage, and there must be at least 4 common opponents * for it to apply. * Consider a scenario where teams A and B are tied up to the common games tie-breaker. * Team A played teams W, X, Y, and Z and had a record of 2-2. * Team B played teams W, X, Y once each and team Z twice, with a record of 2-3. * In this case team A wins the tie-breaker. * ----------------------------------------------------------------------------------*/ StringBuilder msg = new StringBuilder("Games vs common opps: "); List <CTeam> opps = CommonOpponents(ties); Record rec; if (opps.Count < 4) { foreach (var t in ties) { t.Metric += "oXXX"; } if (detailMode) { msg.Append("Less than 4 common opps"); } } else { foreach (var t in ties) { rec = default(Record); foreach (var g in t.teamSchedule) { CTeam opp = g.Opp(t); if (opps.Contains(opp) && !ties.Contains(opp)) { if (g.Winner == t) { rec.w++; } else if (g.WasTie) { rec.t++; } else { rec.l++; } } } t.Metric += 'o' + rec.spct; if (detailMode) { msg.Append(t.teamTag + ":" + rec.wltString + " "); } } } if (detailMode) { tieBreakerSummary.AppendLine(" " + msg.ToString()); } }