-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoeltl_functions.py
243 lines (220 loc) · 12.6 KB
/
poeltl_functions.py
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import pandas as pd
import copy
import random
# team (byg)
# conference (bg)
# division (bg)
# position (byg)
# height (arrow) (byg)
# age (arrow) (byg)
# jersey (arrow) (byg)
west_teams = {'northwest':['DEN','MIN','OKC','UTA','POR'],'pacific':['SAC','PHX','LAC','LAL','GSW'],'southwest':['MEM','DAL','SAS','HOU','NOP']}
east_teams = {'atlantic':['BOS','PHI','NYK','BKN','TOR'],'central':['MIL','CLE','IND','CHI','DET'],'southeast':['MIA','ATL','WAS','ORL','CHA']}
df = pd.read_csv('nba_player_info_updated.csv',index_col=False)
remaining_players = df['Player'].unique().tolist()
remaining_teams = []
remaining_positions = ['G','G-F','F-G','F','F-C','C-F','C']
correct_height = [x for x in range(69,88)]
correct_jersey = [x for x in range(0,100)]
prev_position_guesses = []
def get_initial_guess():
global remaining_teams
global remaining_positions
global correct_height
global correct_jersey
global prev_position_guesses
global west_teams
global east_teams
initial_guess = input('Who was your first guess? ')
initial_guess_info = df.loc[df['Player'] == initial_guess]
prev_position_guesses.append(initial_guess_info['Position'].values[0])
df.drop(df.loc[df['Player']==initial_guess].index, inplace=True)
initial_guess_team = input('What color was TEAM (b, y, or g)? ')
initial_guess_conf = input('What color was CONF (b or g)? ')
initial_guess_div = input('What color was DIV (b or g)? ')
if initial_guess_team == 'g':
remaining_teams = [initial_guess_info['Team'].values[0]]
elif initial_guess_conf == 'b' and initial_guess_div == 'b':
if any(initial_guess_info['Team'].values[0] in div for div in west_teams.values()):
for teams in east_teams.values():
remaining_teams += teams
else:
for teams in west_teams.values():
remaining_teams += teams
elif initial_guess_conf == 'g':
if initial_guess_div == 'b':
if any(initial_guess_info['Team'].values[0] in div for div in west_teams.values()):
remaining_west_teams = copy.deepcopy(west_teams)
for div in west_teams:
if initial_guess_info['Team'].values[0] in west_teams[div]:
del remaining_west_teams[div]
for teams in remaining_west_teams.values():
remaining_teams += teams
else:
remaining_east_teams = copy.deepcopy(east_teams)
for div in east_teams:
if initial_guess_info['Team'].values[0] in east_teams[div]:
del remaining_east_teams[div]
for teams in remaining_east_teams.values():
remaining_teams += teams
elif initial_guess_div == 'g':
if any(initial_guess_info['Team'].values[0] in div for div in west_teams.values()):
for div in west_teams:
if initial_guess_info['Team'].values[0] in west_teams[div]:
remaining_teams = west_teams[div]
remaining_teams.remove(initial_guess_info['Team'].unique().tolist()[0])
else:
for div in east_teams:
if initial_guess_info['Team'].values[0] in east_teams[div]:
remaining_teams = east_teams[div]
remaining_teams.remove(initial_guess_info['Team'].unique().tolist()[0])
initial_guess_pos = input('What color was POS (b, y, or g)? ')
if initial_guess_pos == 'g':
remaining_positions = [initial_guess_info['Position'].values[0]]
elif initial_guess_pos == 'y':
if initial_guess_info['Position'].values[0] == 'G':
remaining_positions = remaining_positions[1:3]
elif initial_guess_info['Position'].values[0] == ('G-F' or 'F-G'):
remaining_positions = remaining_positions[0:6]
remaining_positions.remove(initial_guess_info['Position'].values[0])
elif initial_guess_info['Position'].values[0] == 'F':
remaining_positions = remaining_positions[1:6]
remaining_positions.remove(initial_guess_info['Position'].values[0])
elif initial_guess_info['Position'].values[0] == ('F-C' or 'C-F'):
remaining_positions = remaining_positions[1:7]
remaining_positions.remove(initial_guess_info['Position'].values[0])
elif initial_guess_info['Position'].values[0] == 'C':
remaining_positions = remaining_positions[4:6]
elif initial_guess_pos == 'b':
if initial_guess_info['Position'].values[0] == 'G':
remaining_positions = remaining_positions[3:]
elif initial_guess_info['Position'].values[0] == ('G-F' or 'F-G'):
remaining_positions = remaining_positions[5:]
elif initial_guess_info['Position'].values[0] == 'F':
remaining_positions = ['G','C']
elif initial_guess_info['Position'].values[0] == ('F-C' or 'C-F'):
remaining_positions = remaining_positions[:2]
elif initial_guess_info['Position'].values[0] == 'C':
remaining_positions = remaining_positions[0:4]
initial_guess_height = input('What color was HT (b, y, or g)? ')
initial_guess_height_range = [x for x in range(initial_guess_info['Height'].values[0]-2,initial_guess_info['Height'].values[0]+3)]
if initial_guess_height == 'b':
correct_height = [height for height in correct_height if height not in initial_guess_height_range]
elif initial_guess_height == 'y':
correct_height = initial_guess_height_range
elif initial_guess_height == 'g':
correct_height = [initial_guess_info['Height'].values[0]]
initial_guess_age = input('What color was AGE (b, y, or g)? ')
initial_guess_jersey = input('What color was # (b, y, or g)? ')
initial_guess_jersey_range = [x for x in range(initial_guess_info['Number'].values[0]-2,initial_guess_info['Number'].values[0]+3)]
if initial_guess_jersey == 'b':
correct_jersey = [jersey for jersey in correct_jersey if jersey not in initial_guess_jersey_range]
elif initial_guess_jersey == 'y':
correct_jersey = initial_guess_jersey_range
elif initial_guess_jersey == 'g':
correct_jersey = [initial_guess_info['Number'].values[0]]
remove_unfitting_players()
def get_subsequent_guess():
global remaining_teams
global remaining_positions
global correct_height
global correct_jersey
global prev_position_guesses
global west_teams
global east_teams
subsequent_guess = input('Who was your next guess? ')
subsequent_guess_info = df.loc[df['Player'] == subsequent_guess]
prev_position_guesses.append(subsequent_guess_info['Position'].values[0])
df.drop(df.loc[df['Player']==subsequent_guess].index, inplace=True)
subsequent_guess_team = input('What color was TEAM (b, y, or g)? ')
subsequent_guess_conf = input('What color was CONF (b or g)? ')
subsequent_guess_div = input('What color was DIV (b or g)? ')
if subsequent_guess_team == 'g':
remaining_teams = [subsequent_guess_info['Team'].values[0]]
elif subsequent_guess_conf == 'g':
if subsequent_guess_div == 'b':
if any(subsequent_guess_info['Team'].values[0] in div for div in west_teams.values()):
for div in west_teams:
if subsequent_guess_info['Team'].values[0] in west_teams[div]:
remaining_teams = [team for team in remaining_teams if team not in west_teams[div]]
else:
for div in east_teams:
if subsequent_guess_info['Team'].values[0] in east_teams[div]:
remaining_teams = [team for team in remaining_teams if team not in east_teams[div]]
elif subsequent_guess_div == 'g':
if any(subsequent_guess_info['Team'].values[0] in div for div in west_teams.values()):
for div in west_teams:
if subsequent_guess_info['Team'].values[0] in west_teams[div]:
remaining_teams = west_teams[div]
remaining_teams.remove(subsequent_guess_info['Team'].unique().tolist()[0])
else:
for div in east_teams:
if subsequent_guess_info['Team'].values[0] in east_teams[div]:
remaining_teams = east_teams[div]
remaining_teams.remove(subsequent_guess_info['Team'].unique().tolist()[0])
subsequent_guess_pos = input('What color was POS (b, y, or g)? ')
if subsequent_guess_pos == 'g':
remaining_positions = [subsequent_guess_info['Position'].values[0]]
elif subsequent_guess_pos == 'y':
if subsequent_guess_info['Position'].values[0] == 'G':
remaining_positions = [pos for pos in remaining_positions[1:3] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == ('G-F' or 'F-G'):
remaining_positions = [pos for pos in remaining_positions[0:6] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == 'F':
remaining_positions = [pos for pos in remaining_positions[1:6] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == ('F-C' or 'C-F'):
remaining_positions = [pos for pos in remaining_positions[1:7] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == 'C':
remaining_positions = [pos for pos in remaining_positions[4:6] if pos not in prev_position_guesses]
if subsequent_guess_info['Position'].values[0] in remaining_positions:
remaining_positions.remove(subsequent_guess_info['Position'].values[0])
elif subsequent_guess_pos == 'b':
if subsequent_guess_info['Position'].values[0] == 'G':
remaining_positions = [pos for pos in remaining_positions[3:] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == ('G-F' or 'F-G'):
remaining_positions = [pos for pos in remaining_positions[5:] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == 'F':
remaining_positions = [pos for pos in ['G','C'] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == ('F-C' or 'C-F'):
remaining_positions = [pos for pos in remaining_positions[:2] if pos not in prev_position_guesses]
elif subsequent_guess_info['Position'].values[0] == 'C':
remaining_positions = [pos for pos in remaining_positions[0:4] if pos not in prev_position_guesses]
if subsequent_guess_info['Position'].values[0] in remaining_positions:
remaining_positions.remove(subsequent_guess_info['Position'].values[0])
subsequent_guess_height = input('What color was HT (b, y, or g)? ')
subsequent_guess_height_range = [x for x in range(subsequent_guess_info['Height'].values[0]-2,subsequent_guess_info['Height'].values[0]+3)]
if subsequent_guess_height == 'b':
correct_height = [height for height in correct_height if height not in subsequent_guess_height_range]
elif subsequent_guess_height == 'y':
correct_height = subsequent_guess_height_range
elif subsequent_guess_height == 'g':
correct_height = [subsequent_guess_info['Height'].values[0]]
subsequent_guess_age = input('What color was AGE (b, y, or g)? ')
subsequent_guess_jersey = input('What color was # (b, y, or g)? ')
subsequent_guess_jersey_range = [x for x in range(subsequent_guess_info['Number'].values[0]-2,subsequent_guess_info['Number'].values[0]+3)]
if subsequent_guess_jersey == 'b':
correct_jersey = [jersey for jersey in correct_jersey if jersey not in subsequent_guess_jersey_range]
elif subsequent_guess_jersey == 'y':
correct_jersey = subsequent_guess_jersey_range
elif subsequent_guess_jersey == 'g':
correct_jersey = [subsequent_guess_info['Number'].values[0]]
remove_unfitting_players()
def remove_unfitting_players():
global df
global remaining_players
df = df[df['Team'].isin(remaining_teams)]
df = df[df['Number'].isin(correct_jersey)]
df = df[df['Position'].isin(remaining_positions)]
df = df[df['Height'].isin(correct_height)]
remaining_players = df['Player'].unique().tolist()
get_initial_guess()
for num in range (0,7):
is_guess_correct = input('Was that right (y or n)? ')
if is_guess_correct != 'y':
print('The remaining players are: \n',remaining_players)
print('You should guess ' + random.choice(remaining_players) + ' next!')
get_subsequent_guess()
num += 1
else:
print('Yay!')
break