Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def readfiletolist(filename):
- data = []
- with open(filename, "r") as a:
- data = a.read()
- data = data.replace("\n","")
- data = data.split("-")
- del data[-1]
- return(data)
- data = readfiletolist("stats.txt")
- stat_types = []
- stat_worths = []
- for i in range(len(data)):
- if (i % 2 ) == 0:
- stat_types.append(data[i])
- else:
- stat_worths.append(float(data[i]))
- def calculateWinLoss(team,list_position): ##list_position is the position of the stat "lineup's number of maps played"
- winloss = team[list_position+1] / team[list_position] ##make sure "lineup's number of wins" comes right after
- del team[list_position+1]
- team.append(winloss)
- return(team)
- def teamRankingFix(t1,t2,list_position): ##list_position is the position of the stat "current ranking"
- t1[list_position], t2[list_position] = t2[list_position],t2[list_position]
- t1[list_position+1], t2[list_position+1] = t2[list_position+1],t2[list_position+1] ##make sure peak ranking" comes right after
- return(t1,t2)
- def askTeamInfo(team,stat_types):
- for i in range(len(stat_types)):
- team.append(int(input("{}'s {}".format(team[0],stat_types[i]))))
- return(team)
- def comparison(team1,team2,worths):
- t1score = 0
- t2score = 0
- t1 = team1[:]
- t2 = team2[:]
- del t1[0]
- del t2[0]
- for i in range(len(t1)):
- if t1[i] != t2[i]:
- big = max(t1[i],t2[i])
- small = min(t1[i],t2[i])
- abs_dif = abs(big-small) ##absolute difference between the 2 values
- average = (big + small) / 2 ##average of the 2 values
- percent_dif = abs_dif / average ##divide the difference by the average to get percent difference
- big_score = percent_dif * worths[i]
- print("{} {}".format(big,big_score))
- print("{} {}".format(small,worths[i]-big_score))
- if t1[i] == big:
- t1score += big_score
- t2score += worths[i] - big_score
- else:
- t2score += big_score
- t1score += worths[i] - big_score
- else:
- t1score += worths[i] / 2
- t2score += worths[i] / 2
- return(t1score,t2score)
- team1 = []
- team2 = []
- team1.append(input("What is Team1's Name?"))
- team1 = askTeamInfo(team1,stat_types)
- team2.append(input("What is Team2's Name?"))
- team2 = askTeamInfo(team2,stat_types)
- ##team1,team2 = teamRankingFix(team1,team2,5)
- team1 = calculateWinLoss(team1,7)
- team2 = calculateWinLoss(team2,7)
- team1score,team2score = comparison(team1,team2,stat_worths)
- print("{}'s chance to win is {:.2f}%".format(team2[0],team1score))
- print("{}'s chance to win is {:.2f}%".format(team1[0],team2score))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement