-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorkoutRecommender.py
More file actions
180 lines (163 loc) · 7.07 KB
/
WorkoutRecommender.py
File metadata and controls
180 lines (163 loc) · 7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
from HealthBasedGoal import HealthBasedGoal
from ImageBasedGoal import ImageBasedGoal
from WeightBasedGoal import WeightBasedGoal
from LowGoal import LowGoal
from person import Person
from strength import Strength
from exerciseclass import ExerciseClass
from cardio import Cardio
from environment import Environment
from temperature import Temperature
from altitude import Altitude
from health import Health
from physicalHealth import PhysicalHealth
from mentalHealth import MentalHealth
from random import randint
class WorkoutRecommender:
def __init__(self):
return
def start(self):
p1 = Person()
p1.interview()
ph1 = PhysicalHealth()
mh1 = MentalHealth()
injury = ph1.generateInjury()
t1 = Temperature()
t1 = t1.getTemp(zip)
pr1 = Altitude()
pr1 = pr1.getPressure(zip)
stress = mh1.generateStress()
sick = ph1.generateSick()
strength = False
if p1.enthusiasm == '1' or p1.experience == '1':
self.goal = LowGoal()
elif p1.goal == '1':
self.goal = HealthBasedGoal()
elif p1.goal == '2':
self.goal = ImageBasedGoal()
elif p1.goal == '3':
strength = True
self.goal = WeightBasedGoal()
# READY TO OUTPUT THE GOAL'S EXECUTION PLAN in nice format
print("WORKOUT 1")
for ex in self.goal.execution_plan:
# environment adjustment
# temperature
if t1 >= 80:
ex.duration -= 3
print("Because of the heat, your workout was shortened to ", ex.duration, " minutes")
elif t1 <= 50:
print("Because of the low temperature of ", t1,
" degrees, you should do a 5 minute warm-up jog.")
else:
print("Temperature outside is ", t1, ". Enjoy your workout!")
# altitude
if pr1 >= 1843:
if ex.duration >= 15:
ex.duration -= 5
print("The air is thinner, affecting physical performance. Workout has been "
"shortened to ", ex.duration, " minutes")
else:
print("Atmospheric pressure of ", pr1, " hPA shouldn't affect workout.")
# health adjustment
if injury == '2':
if strength:
print("If you are injured, use low weights or no weights at all "
"- use resistance bands and bodyweight instead.")
else:
print("Given your injury, if anything feels hurt during your workout, "
"stop what you're doing and RICE it.")
if sick == '2':
print("If you feel sick with above the neck, you can workout as usual, just monitor "
"how you feel. If you feel sick below the neck, take today as a rest day!")
if (stress == '2') | (stress == '3'):
if strength:
print(
"Consider doing a superset so your workout takes less time (no rest between exercises.)")
else:
if ex.duration >= 15:
ex.duration -= 5
print("Workout shortened to account for stress.")
print(ex)
workoutNum = 2
while True:
opinion = input("Was that workout easy(1), ok(2), hard(3) or would you like to quit(4)")
if int(opinion) > 3:
exit()
adjust = input("Do you want to adjust the current plan(1) or create a new one(2)?")
if adjust == '1':
if opinion == '1':
print("The workout will be harder by increasing reps/sets")
for ex in self.goal.execution_plan:
if isinstance(ex, Strength):
if ex.reps < 10:
ex.reps += 2
else:
ex.sets += 1
ex.reps = randint(6,8)
elif isinstance(ex, Cardio):
if ex.type == 'Treadmill':
ex.duration += 10
else:
ex.type = 'Treadmill'
elif isinstance(ex, ExerciseClass):
num = randint(1,3)
if num == 1:
ex.duration += 15
if num == 2:
if p1.goal == '1':
self.goal = HealthBasedGoal()
elif p1.goal == '2':
self.goal = ImageBasedGoal()
elif p1.goal == '3':
self.goal = WeightBasedGoal()
else:
self.goal = LowGoal()
elif opinion == '2':
print("The workout will be similar by slightly increasing reps/sets")
for ex in self.goal.execution_plan:
if isinstance(ex, Strength):
if ex.reps < 12:
ex.reps += 1
else:
ex.sets += 1
ex.reps = randint(6,8)
elif isinstance(ex, Cardio):
ex.duration += 5
elif opinion == '3':
print("The workout will be easier by slightly decreasing reps/sets")
for ex in self.goal.execution_plan:
if isinstance(ex, Strength):
if ex.reps > 6:
ex.reps -= 1
else:
ex.sets -= 1
ex.reps = randint(8,12)
elif isinstance(ex, Cardio):
ex.duration -= 10
elif isinstance(ex, ExerciseClass):
num = randint(1,2)
if num == 1:
ex.duration -= 15
else:
self.goal = LowGoal()
elif adjust == '2':
print("A new workout will be made")
p1.interview()
if p1.enthusiasm == '1' or p1.experience == '1':
self.goal = LowGoal()
elif p1.goal == '1':
self.goal = HealthBasedGoal()
elif p1.goal == '2':
self.goal = ImageBasedGoal()
elif p1.goal == '3':
self.goal = WeightBasedGoal()
print("WORKOUT " + str(workoutNum))
workoutNum += 1
for ex in self.goal.execution_plan:
print(ex)
def main():
wr = WorkoutRecommender()
wr.start()
if __name__ == '__main__':
main()