Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GradePredictor/GradeGuesser.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
69 lines (60 sloc)
1.74 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def GradeGuesserMain(wallAngle, holds): | |
avgHold, length = HoldScorer(holds) | |
angleAdjust = AngleScorer(wallAngle) | |
lengthAdjust = LengthAdjust(avgHold, length) | |
grade = GradePredictor(avgHold, lengthAdjust, angleAdjust) | |
return grade | |
def HoldScorer(holds): | |
score = 0 | |
numOfHolds = 0 | |
for i in holds: | |
score += holds[numOfHolds] | |
numOfHolds += 1 | |
return score/numOfHolds, numOfHolds | |
def AngleScorer(wallAngle): | |
n = 0 | |
if wallAngle > 90 and wallAngle < 180: | |
wallAngle -= 90 | |
for i in range(0, wallAngle): | |
n += 0.02 | |
return 1 + n | |
elif wallAngle <= 90 and wallAngle >= 0: | |
for i in range(0, wallAngle): | |
n += 0.01 | |
return 1 - n | |
def LengthAdjust(avgHold, length): | |
if length > 10: | |
if avgHold < 10: | |
return 1 | |
elif avgHold < 20: | |
return ((length - 10)*0.1 + 1 ) | |
else: | |
return ((length - 10)*0.2 + 1 ) | |
return 1 | |
def GradePredictor(avgHold, lengthAdjust, angleAdjust): | |
score = avgHold*lengthAdjust*angleAdjust | |
print("""Average Hold Score: {0} | |
Length Adjustment Score: {1} | |
Angle Adjustment Score: {2} | |
Final Grade Score: {3}""".format(avgHold, lengthAdjust, angleAdjust, score)) | |
if score <= 5: | |
return "V0" | |
if score <= 10: | |
return "V1" | |
if score <= 15: | |
return "V2" | |
if score <= 20: | |
return "V3" | |
if score <= 25: | |
return "V4" | |
if score <= 30: | |
return "V5" | |
if score <= 35: | |
return "V6" | |
if score <= 40: | |
return "V7" | |
else: | |
return "V8+" | |
#wallAngle = 75 | |
#holds = [8, 7, 14, 7, 8, 12, 12, 10, 7] | |
#GradeGuesserMain(wallAngle, holds) |