Skip to content

Instantly share code, notes, and snippets.

@j-k-projects
Forked from akeaswaran/pollscore.m
Created November 8, 2019 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-k-projects/02b248c79bfb5448d0e375fdbfaf8efb to your computer and use it in GitHub Desktop.
Save j-k-projects/02b248c79bfb5448d0e375fdbfaf8efb to your computer and use it in GitHub Desktop.
Calculating poll score in CFC
-(void)updateStrengthOfWins {
int strWins = 0;
for ( int i = 0; i < gameSchedule.count; ++i ) {
Game *g = gameSchedule[i];
if (g.homeTeam == self) {
strWins += pow(60 - g.awayTeam.rankTeamPollScore,2);
} else {
strWins += pow(60 - g.homeTeam.rankTeamPollScore,2);
}
}
teamStrengthOfWins = strWins/50;
for (Team *t in gameWinsAgainst) {
teamStrengthOfWins += pow(t.wins,2);
}
}
-(void)updatePollScore {
[self updateStrengthOfWins];
int preseasonBias = 8 - (wins + losses);
if (preseasonBias < 0) preseasonBias = 0;
teamPollScore = (wins*200 + 3*(teamPoints-teamOppPoints) + (teamYards-teamOppYards)/40 + (teamStrengthOfWins / 2) + 3*(preseasonBias)*(teamPrestige + [self getOffensiveTalent] + [self getDefensiveTalent]) + teamStrengthOfWins)/11 + (teamPrestige / 5);
if ([@"CC" isEqualToString:confChampion] ) {
//bonus for winning conference
teamPollScore += 25;
}
if ( [@"NCW" isEqualToString:natlChampWL] ) {
//bonus for winning champ game
teamPollScore += 100;
}
if ( [@"NCL" isEqualToString:natlChampWL] ) {
//bonus for winning champ game
teamPollScore += 15;
}
if (losses == 0) {
teamPollScore += 30;
} else if (losses == 1 ) {
teamPollScore += 15;
} else {
teamPollScore += 0;
}
if (teamPollScore < 0) {
teamPollScore = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment