def _play(self, madness): # See if superclass wants to handle the matchup status, winner, loser = Matchup.base_play(self.teams[0], self.teams[1]) if status: # Superclass handled the matchup self.winner = winner self.loser = loser return (self.winner, self.loser) seq = [1,2] val = random.choice(seq) if val == 1: self.winner = self.teams[0] self.loser = self.teams[1] else: self.winner = self.teams[1] self.loser = self.teams[0] return (self.winner, self.loser)
def _play(self, madness): # See if superclass wants to handle the matchup status, self.winner, self.loser = Matchup.base_play(self.team1['team'], self.team2['team']) if status: # Superclass handled the matchup return (self.winner, self.loser) # High seed is seed with larger number (worse) # Low seed is seed with smaller number (better team) highseed = self.team1 lowseed = self.team2 if lowseed['mad_seed'] > highseed['mad_seed']: highseed = self.team2 lowseed = self.team1 # Seeds are the same, coin flip if highseed['mad_seed'] == lowseed['mad_seed']: self.winner,self.loser = self._coin_flip(highseed,lowseed) return (self.winner, self.loser) # Seeds are off by one, coin flip if highseed['mad_seed'] - lowseed['mad_seed'] == 1: self.winner,self.loser = self._coin_flip(highseed,lowseed) return (self.winner, self.loser) if madness: # Adjust lowseed (which is the better team) up a notch lowseed['mad_seed'] = lowseed['mad_seed'] + 1 return self._play(madness-1) highrange = range(lowseed['mad_seed'],highseed['mad_seed']) r = random.randrange(lowseed['mad_seed'],highseed['mad_seed']+1) if r in highrange: self.winner = lowseed['team'] self.loser = highseed['team'] else: self.winner = highseed['team'] self.loser = lowseed['team'] return (self.winner, self.loser)