# -*- coding: utf-8 -*-
"""SportsSim.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1p08sqBskDAiJMnXCDH0s1unxxSr-uI5I
"""

import random as rnd

class Team:
  def __init__(self,Offense,o_std, Defense,d_std):
    self.Offense = Offense
    self.o_std = o_std
    self.Defense = Defense
    self.d_std = d_std


def game_sim(HomeTeam, AwayTeam, HomeFieldAdvantage,PointSpread):
  teamA = HomeTeam
  teamB = AwayTeam
  TeamAScore = int((rnd.gauss(teamA.Offense,teamA.o_std)+rnd.gauss(teamB.Defense,teamB.d_std))/2) + HomeFieldAdvantage + PointSpread
  TeamBScore = int((rnd.gauss(teamB.Offense,teamB.o_std)+rnd.gauss(teamA.Defense,teamA.d_std))/2)
  if TeamAScore > TeamBScore:
    return 1
  if TeamBScore > TeamAScore:
    return -1


def multisim(number_of_sims,Home,Away,HFA,PointSpread):
    gamesout = []
    team1win = 0
    team2win = 0
    tie = 0
    for i in range(number_of_sims):
        gm = game_sim(Home,Away,HFA,PointSpread)
        gamesout.append(gm)
        if gm == 1 :
            team1win += 1
        elif gm == -1:
            team2win +=1
        else: tie +=1
    print('Home Team Covers: ', round((team1win)/(team1win+team2win+tie)*100,2),'%')
    print('Away Team Covers: ', round((team2win)/(team1win+team2win+tie)*100,2),'%')
    print('Push: ', round(tie/(team1win+team2win+tie)*100,2), '%')
