-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiles.py
203 lines (190 loc) · 10.1 KB
/
profiles.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
class Attribute:
def __init__(self, yours, preference, scale):
self.yours = yours
self.preference = preference
self.scale = scale
# def __str__(self):
# return str(self.yours)
class Profile:
def __init__(self, name,
gender, genderPreference,
height, heightPreference, heightScale,
age, agePreference,
religion, religionScale,
politics, politicsScale,
introExtrovert, introExtrovertPreference, introExtrovertScale,
smoke, smokePreference, smokeScale,
messyNeat, messyNeatPreference, messyNeatScale,
dogCat, dogCatScale,robot,email,pic):
#Basic self info
self.name = name
self.gender = gender
self.genderPreference = genderPreference
#Basic items with scales (age,height,weight)
self.height = Attribute(height,heightPreference,heightScale)
self.age = Attribute(age, agePreference,1)
#Basic items with preferences
self.religion = Attribute(religion, religion, religionScale)
self.politics = Attribute(politics,politics,politicsScale)
self.introExtrovert = Attribute(introExtrovert,introExtrovertPreference,introExtrovertScale)
self.smoke = Attribute(smoke, smokePreference, smokeScale)
self.messyNeat = Attribute(messyNeat, messyNeatPreference, messyNeatScale)
#Random
self.dogCat = Attribute(dogCat,dogCat, dogCatScale)
self.robot = robot
self.email = email
self.pic = pic
def __str__(self):
return str(self.name)
def getProfileList(self):
return [self.name,
self.gender, self.genderPreference,
self.height.yours, self.height.preference, self.height.scale,
self.age.yours, self.age.preference,
self.religion.yours , self.religion.scale,
self.politics.yours,self.politics.scale,
self.introExtrovert.yours, self.introExtrovert.preference, self.introExtrovert.scale,
self.smoke.yours, self.smoke.preference, self.smoke.scale,
self.messyNeat.yours, self.messyNeat.preference, self.messyNeat.scale,
self.dogCat.yours, self.dogCat.scale,self.robot, self.email,self.pic]
def find_hated(self,profileList):
matchList = []
for p in range(len(profileList)):
hatred = 0
#checks you are the correct gender/age for the other person and vice versa
if (profileList[p].gender != self.genderPreference) or not(profileList[p].age.yours in self.age.preference) or (self.gender != profileList[p].genderPreference) or not(self.age.yours in profileList[p].age.preference):
matchList.append(0)
continue
for k in self.__dict__:
if k == "name" or k == "gender" or k == "genderPreference" or k == "age" or k == "robot" or k == "pic" or k == "email":
continue
#calculates the amount of difference for hieght, weight, and age
elif k == "height":
#if your H/W is bigger/smaller than thier preference, add the difference squared times 100
if self.__dict__[k].yours > profileList[p].__dict__[k].preference[-1]:
val = abs(self.__dict__[k].yours - profileList[p].__dict__[k].preference[-1])**2/100
if val <= 5:
hatred += val
else:
hatred += 5
elif self.__dict__[k].yours < profileList[p].__dict__[k].preference[0]:
val = abs(self.__dict__[k].yours - profileList[p].__dict__[k].preference[0])**2/100
if val <= 5:
hatred += val
else:
hatred += 5
#if their H/W is bigger/smaller than your preference, add the difference squared times 100
if profileList[p].__dict__[k].yours > self.__dict__[k].preference[-1]:
val = abs(profileList[p].__dict__[k].yours - self.__dict__[k].preference[-1])**2/100
if val <= 5:
hatred += val
else:
hatred += 5
elif profileList[p].__dict__[k].yours < self.__dict__[k].preference[0]:
val = abs(profileList[p].__dict__[k].yours - self.__dict__[k].preference[0])**2/100
if val <= 5:
hatred += val
else:
hatred += 5
#for all other params, add the scale if different
else:
if self.__dict__[k].preference != profileList[p].__dict__[k].yours:
hatred += 1 * self.__dict__[k].scale
if self.__dict__[k].yours != profileList[p].__dict__[k].preference:
hatred += 1 * self.__dict__[k].scale
matchList.append(hatred)
maxMatch = 0
worstPerson = 0
for i in range(len(profileList)):
if matchList[i] > maxMatch:
maxMatch = matchList[i]
worstPerson = i
print(profileList[i].name + ":" + str(matchList[i]))
print(matchList)
return profileList[worstPerson].getProfileList()
def find_opposite(self,profileList):
matchList = []
for p in range(len(profileList)):
Oppositeness = 0
#Break if the person is outside of your age or gender preference (or you're outside of theirs) - For these items, we do not want the opposite
if (profileList[p].gender != self.genderPreference) or not(profileList[p].age.yours in self.age.preference) or (self.gender != profileList[p].genderPreference) or not (self.age.yours in profileList[p].age.preference) :
matchList.append(0)
continue
for k in self.__dict__:
if k == "name" or k == "gender" or k == "genderPreference" or k == "age" or k == "robot" or k == "pic" or k == "email":
continue
#calculates the amount of difference for hieght, weight, and age
elif k == "height":
val = abs(self.__dict__[k].yours-profileList[p].__dict__[k].yours)**2/100
if val <= 5:
Oppositeness += val
else:
Oppositeness += 5
else:
if self.__dict__[k].yours != profileList[p].__dict__[k].yours:
Oppositeness += 1
matchList.append(Oppositeness)
maxMatch = 0
worstPerson = 0
for i in range(len(profileList)):
if matchList[i] > maxMatch:
maxMatch = matchList[i]
worstPerson = i
print(profileList[i].name + ":" + str(matchList[i]))
print(matchList)
return profileList[worstPerson].getProfileList()
def find_friend_zone(self,profileList):
matchList = []
for p in range(len(profileList)):
awkwardness = 0
#checks you are the correct gender/age for the other person and vice versa
if (profileList[p].gender != self.genderPreference) or not(profileList[p].age.yours in self.age.preference) or (self.gender != profileList[p].genderPreference) or not (self.age.yours in profileList[p].age.preference):
matchList.append(0)
continue
for k in self.__dict__:
if k == "name" or k == "gender" or k == "genderPreference" or k == "age" or k == "robot" or k == "pic" or k == "email":
continue
#calculates the amount of difference for hieght, weight, and age
elif k == "height":
#if your H/W is bigger/smaller than thier preference, add the difference squared times 100
if self.__dict__[k].yours > profileList[p].__dict__[k].preference[-1]:
val = abs(self.__dict__[k].yours - profileList[p].__dict__[k].preference[-1])**2/100
if val <= 5:
awkwardness += val
else:
awkwardness += 5
elif self.__dict__[k].yours < profileList[p].__dict__[k].preference[0]:
val = abs(self.__dict__[k].yours - profileList[p].__dict__[k].preference[0])**2/100
if val <= 5:
awkwardness += val
else:
awkwardness += 5
#if their H/W is bigger/smaller than your preference, add the difference squared times 100
if profileList[p].__dict__[k].yours > self.__dict__[k].preference[-1]:
val = abs(profileList[p].__dict__[k].yours - self.__dict__[k].preference[-1])**2/100
if val <= 5:
awkwardness += val
else:
awkwardness += 5
elif profileList[p].__dict__[k].yours < self.__dict__[k].preference[0]:
val = abs(profileList[p].__dict__[k].yours - self.__dict__[k].preference[0])**2/100
if val <= 5:
awkwardness += val
else:
awkwardness += 5
#for all other params, add the scale if different for you or same for them
else:
if self.__dict__[k].preference != profileList[p].__dict__[k].yours:
awkwardness += 1 * self.__dict__[k].scale
if self.__dict__[k].yours == profileList[p].__dict__[k].preference:
awkwardness += 1 * self.__dict__[k].scale
matchList.append(awkwardness)
maxMatch = 0
worstPerson = 0
for i in range(len(profileList)):
if matchList[i] > maxMatch:
maxMatch = matchList[i]
worstPerson = i
print(profileList[i].name + ":" + str(matchList[i]))
print(matchList)
return profileList[worstPerson].getProfileList()