From 6428566f2724d962d3f4d3d5a0102cdcdc03478d Mon Sep 17 00:00:00 2001
From: P <81023255+zestyoreo@users.noreply.github.com>
Date: Tue, 19 Oct 2021 23:29:23 +0530
Subject: [PATCH 1/5] added coder class and changes simulations to accommodate
more types of people in the future
---
.DS_Store | Bin 0 -> 6148 bytes
200050103/.DS_Store | Bin 0 -> 6148 bytes
200050103/README.md | 49 ++++++++++++
200050103/people.py | 98 +++++++++++++++++++++++
200050103/simulation.py | 171 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 318 insertions(+)
create mode 100644 .DS_Store
create mode 100644 200050103/.DS_Store
create mode 100644 200050103/README.md
create mode 100644 200050103/people.py
create mode 100644 200050103/simulation.py
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..57f6f555259be2a6d4bf53df7da79f9b579d95e6
GIT binary patch
literal 6148
zcmeHKJ&)5c7=GO=kZ`J~1k%BP6b81cYRZul15zoyp#u^k2nImCq^Yiv(l}~Us-qNj
zU}Ip1fuF#SU}Hz@{0k;{?D(J`IjPf$Lw>8*k7K`&Kb|;tO+>6Y4s4<_5gBlS#fwOC
zOwjWO*^Zl4$c{SYYtw1Hey3vD
zjx(!RQ@iFk6>Hbooy|;R=cawPeK0tBHGMsM^Fhvr77b2Z?%*n#*H6uoloz-+&d{U*f28bZ_@KicNj-JK16R~X4}-kFQFsqk_YcoPn5Ky
z#dl0%Y|HOBK^zA!0#*fonZd5FFfJqJFQX$@Re)8sC)d^WaZKI?62-
z*HAdmFryPwmk*|TX6lB*WbbI-lHtS}8R}FkpcPnFU@Lnpi}Qc~UodN?`hrfRsTe
JT7gql;5QA(&j$bi
literal 0
HcmV?d00001
diff --git a/200050103/.DS_Store b/200050103/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..bd25237a9f4804d9eeea5a4fd59ccf51b1acf6c2
GIT binary patch
literal 6148
zcmeHKyH3ME5S)b+K?unu<$XaU{=h^|k%9((076nA8H@xe==|p}`v@Y5l@bNCE8Wg|
zA9v@GeCGuq)AjNSr~r&P6h(~zQTJfzB$7{wVso@uVS-nD%-ey9j?txiKjV&9=%|0}
zzk6J?-Gb5Tb4RS=7BgI{&GtOX#B=r*CPy@b}3z&fyZWP~DK
zO7v2R7DK$8{t|h0VDISVkZ3+6R^Bu(VykohV(F0DF?BMK3~V!?y)UKG`+vqyX0XY(
zlvK$;GVos+kWq8jO!;Created with :heart: by WnCC
+
diff --git a/200050103/people.py b/200050103/people.py
new file mode 100644
index 0000000..4177d39
--- /dev/null
+++ b/200050103/people.py
@@ -0,0 +1,98 @@
+## Class for people defining various parameters such as acads, extracurriculars, tech, cult etc
+## Various member functions are defined indicating the effect of a particular activity
+import random
+types_of_people = 2 #change this variable with more number of people
+class people():
+ def __init__(self):
+ self.academics = 20
+ self.extracur = 15
+ self.technical = 15
+ self.cult = 15
+ self.fitness = 75
+ self.mental_health = 75
+ self.happiness = 80
+ self.probs = [0.6, 0.2, 0.2]
+ self.laziness = 0.5
+
+ #max and min:essentially, ranges for the attribute values
+ self.technical_max = 100
+ self.fitness_min = 0
+ self.fitness_max = 200
+ self.laziness_max = 1
+
+ def adjust(self):
+ if self.technical>self.technical_max:
+ self.technical = self.technical_max
+ if self.fitness < self.fitness_min:
+ self.fitness = self.fitness_min
+ if self.fitness > self.fitness_max:
+ self.fitness = self.fitness_max
+ if self.laziness > self.laziness_max:
+ self.laziness = self.laziness_max
+
+ def study(self):
+ self.academics += 0.5
+ self.fitness -= 0.1
+ self.adjust()
+
+ def hobby(self):
+ self.extracur += 0.5
+ self.mental_health += 0.7
+ self.adjust()
+
+ def relax(self):
+ self.mental_health += 0.7
+ self.fitness -= 0.1
+ self.adjust()
+
+ def exercise(self):
+ self.fitness += 1
+ self.mental_health += 0.5
+ self.adjust()
+
+class coder(people):
+ def __init__(self):
+ super().__init__()
+ self.academics += 5
+ self.extracur += 2
+ self.technical += 15
+ self.cult -= 5
+ self.fitness -= 20
+ self.mental_health -= 5
+ self.happiness += 5
+ self.laziness += 1 # ;)
+ self.probs = [0.5, 0.1, 0.2, 0.05, 0.1, 0.05]
+
+ def coding_practice(self):
+ self.extracur += 0.5
+ self.fitness -= 0.5
+ self.adjust()
+
+ def comp_coding(self):
+ self.extracur += 0.5
+ self.fitness -= 0.5
+
+ success = (random.randint(0,10000) <= (self.technical*100)) #success on based on technical skill
+ if success:
+ self.happiness += 1
+ self.mental_health += 0.25
+ else:
+ self.happiness -= 1
+ self.mental_health -= 1.25
+ self.laziness += 0.05
+ self.adjust()
+
+ def contributive_coding(self):
+ self.extracur += 0.5
+ if self.technical= rnd.randint(8, 8+person.laziness*4) or hours <= 17): #Depending on how lazy the person is, it decides when the person starts his day
+
+ ## Randomly choosing between study, hobby and relax according to their weights defined earlier
+
+ work = rnd.choices(['s', 'h', 'r'], person.probs)
+ if work == ["s"]:
+ activities[i].append("studied")
+ person.study()
+ elif work == ["h"]:
+ activities[i].append("hobby")
+ person.hobby()
+ else:
+ activities[i].append("relaxed")
+ person.relax()
+ elif((hours > 4 and hours <= 7) or (hours < 20 and hours > 17)):
+ # For exercising in morning or evening, depends on the laziness of the person
+ e = rnd.choices(['e', 'ne'], [1-person.laziness, person.laziness])[0]
+ if e == "e":
+ person.exercise()
+ if hours == 23 and (activities[i].count("studied")/len(activities[i])) > 0.4:
+ #Studying above a certain limit in a day can cause some amount of mental health detrioration
+ person.mental_health -= 1
+
+ person.academics -= 0.02 #To simulate forgetfullnes, each day you tend to a forget a few things from days back
+ elif type(person)==type(cod):
+ if(hours >= rnd.randint(8, 8+person.laziness*4) or hours <= 17): #Depending on how lazy the person is, it decides when the person starts his day
+
+ ## Randomly choosing between study, hobby and relax according to their weights defined earlier
+
+ work = rnd.choices(['s', 'h', 'r','cprac','com_code','contib_code'], person.probs)
+ if work == ["s"]:
+ activities[i].append("studied")
+ person.study()
+ elif work == ["h"]:
+ activities[i].append("hobby")
+ person.hobby()
+ elif work == ["r"]:
+ activities[i].append("relaxed")
+ person.relax()
+ elif work == ["cprac"]:
+ activities[i].append("coding practice")
+ person.comp_coding()
+ elif work == ["com_code"]:
+ activities[i].append("competitive coding")
+ person.relax()
+ else:
+ activities[i].append("open source contributions")
+ person.contributive_coding()
+ elif((hours > 4 and hours <= 7) or (hours < 20 and hours > 17)):
+ # For exercising in morning or evening, depends on the laziness of the person
+ e = rnd.choices(['e', 'ne'], [1-person.laziness, person.laziness])[0]
+ if e == "e":
+ person.exercise()
+ if hours == 23 and (activities[i].count("studied")/len(activities[i])) > 0.4:
+ #Studying above a certain limit in a day can cause some amount of mental health detrioration
+ person.mental_health -= 1
+
+ person.academics -= 0.02 #To simulate forgetfullnes, each day you tend to a forget a few things from days back
+
+ ## Appending the arrays according to the activities and the choices in a day
+
+ acads = []
+ for person in population:
+ acads.append(person.academics)
+ extracurs = []
+ for person in population:
+ extracurs.append(person.extracur)
+
+ mental_healths = []
+ for person in population:
+ mental_healths.append(person.mental_health)
+
+ physical_healths = []
+ for person in population:
+ physical_healths.append(person.fitness)
+
+ ## Plotting the results
+
+ plt.subplot(4, 1, 1)
+ plt.plot(range(100), acads, color='darkblue')
+ plt.xlabel("Person")
+ plt.ylabel("Academic Level")
+ plt.subplot(4, 1, 2)
+ plt.plot(range(100), extracurs, color='green')
+ plt.xlabel("Person")
+ plt.ylabel("Extracurricular Level")
+ plt.subplot(4, 1, 3)
+ plt.plot(range(100), mental_healths, color='orange')
+ plt.xlabel("Person")
+ plt.ylabel("Mental Health")
+ plt.subplot(4, 1, 4)
+ plt.plot(range(100), physical_healths, color='red')
+ plt.xlabel("Person")
+ plt.ylabel("Physical Fitness")
+ plt.tight_layout()
+ fig.canvas.mpl_connect("key_press_event", on_press) #Detect key press
+ plt.draw()
+ plt.pause(1)
+ fig.clf()
+
+## Compile data and draw the final graph at the end of the month
+
+acads = []
+for person in population:
+ acads.append(person.academics)
+extracurs = []
+for person in population:
+ extracurs.append(person.extracur)
+
+mental_healths = []
+for person in population:
+ mental_healths.append(person.mental_health)
+
+physical_healths = []
+for person in population:
+ physical_healths.append(person.fitness)
+
+## Plotting the results
+
+
+plt.subplot(4, 1, 1)
+plt.plot(range(100), acads, color='darkblue')
+plt.xlabel("Person")
+plt.ylabel("Academic Level")
+plt.subplot(4, 1, 2)
+plt.plot(range(100), extracurs, color='green')
+plt.xlabel("Person")
+plt.ylabel("Extracurricular Level")
+plt.subplot(4, 1, 3)
+plt.plot(range(100), mental_healths, color='orange')
+plt.xlabel("Person")
+plt.ylabel("Mental Health")
+plt.subplot(4, 1, 4)
+plt.plot(range(100), physical_healths, color='red')
+plt.xlabel("Person")
+plt.ylabel("Physical Fitness")
+plt.tight_layout()
+fig.canvas.mpl_connect("key_press_event", on_press) #Detect key press
+plt.show()
\ No newline at end of file
From c3e6ae64e4e013e634d0fdfac9553ec5ff380771 Mon Sep 17 00:00:00 2001
From: Balasubramanian <81023255+zestyoreo@users.noreply.github.com>
Date: Tue, 19 Oct 2021 23:30:47 +0530
Subject: [PATCH 2/5] Delete .DS_Store
---
.DS_Store | Bin 6148 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 .DS_Store
diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 57f6f555259be2a6d4bf53df7da79f9b579d95e6..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 6148
zcmeHKJ&)5c7=GO=kZ`J~1k%BP6b81cYRZul15zoyp#u^k2nImCq^Yiv(l}~Us-qNj
zU}Ip1fuF#SU}Hz@{0k;{?D(J`IjPf$Lw>8*k7K`&Kb|;tO+>6Y4s4<_5gBlS#fwOC
zOwjWO*^Zl4$c{SYYtw1Hey3vD
zjx(!RQ@iFk6>Hbooy|;R=cawPeK0tBHGMsM^Fhvr77b2Z?%*n#*H6uoloz-+&d{U*f28bZ_@KicNj-JK16R~X4}-kFQFsqk_YcoPn5Ky
z#dl0%Y|HOBK^zA!0#*fonZd5FFfJqJFQX$@Re)8sC)d^WaZKI?62-
z*HAdmFryPwmk*|TX6lB*WbbI-lHtS}8R}FkpcPnFU@Lnpi}Qc~UodN?`hrfRsTe
JT7gql;5QA(&j$bi
From 5cc8f7d8c19381bfd782c5423bcea2563ab48594 Mon Sep 17 00:00:00 2001
From: Balasubramanian <81023255+zestyoreo@users.noreply.github.com>
Date: Tue, 19 Oct 2021 23:30:56 +0530
Subject: [PATCH 3/5] Delete .DS_Store
---
200050103/.DS_Store | Bin 6148 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 200050103/.DS_Store
diff --git a/200050103/.DS_Store b/200050103/.DS_Store
deleted file mode 100644
index bd25237a9f4804d9eeea5a4fd59ccf51b1acf6c2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 6148
zcmeHKyH3ME5S)b+K?unu<$XaU{=h^|k%9((076nA8H@xe==|p}`v@Y5l@bNCE8Wg|
zA9v@GeCGuq)AjNSr~r&P6h(~zQTJfzB$7{wVso@uVS-nD%-ey9j?txiKjV&9=%|0}
zzk6J?-Gb5Tb4RS=7BgI{&GtOX#B=r*CPy@b}3z&fyZWP~DK
zO7v2R7DK$8{t|h0VDISVkZ3+6R^Bu(VykohV(F0DF?BMK3~V!?y)UKG`+vqyX0XY(
zlvK$;GVos+kWq8jO!;
Date: Fri, 22 Oct 2021 07:25:16 +0530
Subject: [PATCH 4/5] increments as per tanh function done
---
200050103/people.py | 29 ++++++++++++++++++++---------
200050103/simulation.py | 2 ++
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/200050103/people.py b/200050103/people.py
index 4177d39..af9d8dc 100644
--- a/200050103/people.py
+++ b/200050103/people.py
@@ -1,6 +1,7 @@
## Class for people defining various parameters such as acads, extracurriculars, tech, cult etc
## Various member functions are defined indicating the effect of a particular activity
import random
+import math
types_of_people = 2 #change this variable with more number of people
class people():
def __init__(self):
@@ -18,7 +19,9 @@ def __init__(self):
self.technical_max = 100
self.fitness_min = 0
self.fitness_max = 200
- self.laziness_max = 1
+ self.laziness_max = 3
+ self.academics_max = 100
+ self.academics_min = 0
def adjust(self):
if self.technical>self.technical_max:
@@ -29,10 +32,19 @@ def adjust(self):
self.fitness = self.fitness_max
if self.laziness > self.laziness_max:
self.laziness = self.laziness_max
+ if self.academics < self.academics_min:
+ self.academics = self.academics_min
+ if self.academics > self.academics_max:
+ self.academics = self.academics_max
+
+ def choose(self,min,max,parameter): #selects value increment or decrement as per tanh function's slope
+ #parameter = (max-min)tanh(x)+min
+ dx = 0.5
+ return (max-min)*(1-math.tanh(parameter))*dx
def study(self):
- self.academics += 0.5
- self.fitness -= 0.1
+ self.academics += self.choose(0,self.academics_max,self.academics)
+ self.fitness -= self.choose(self.fitness_min,self.fitness_max,self.fitness)
self.adjust()
def hobby(self):
@@ -42,11 +54,11 @@ def hobby(self):
def relax(self):
self.mental_health += 0.7
- self.fitness -= 0.1
+ self.fitness -= self.choose(self.fitness_min,self.fitness_max,self.fitness)
self.adjust()
def exercise(self):
- self.fitness += 1
+ self.fitness -= self.choose(self.fitness_min,self.fitness_max,self.fitness)
self.mental_health += 0.5
self.adjust()
@@ -65,7 +77,7 @@ def __init__(self):
def coding_practice(self):
self.extracur += 0.5
- self.fitness -= 0.5
+ self.fitness -= self.choose(self.fitness_min,self.fitness_max,self.fitness)
self.adjust()
def comp_coding(self):
@@ -84,9 +96,8 @@ def comp_coding(self):
def contributive_coding(self):
self.extracur += 0.5
- if self.technical= rnd.randint(8, 8+person.laziness*4) or hours <= 17): #Depending on how lazy the person is, it decides when the person starts his day
@@ -88,6 +89,7 @@ def on_press(event):
person.mental_health -= 1
person.academics -= 0.02 #To simulate forgetfullnes, each day you tend to a forget a few things from days back
+ person.adjust()
## Appending the arrays according to the activities and the choices in a day
From 5b40fe1063dfd742981c434876bbcea0be33d2a6 Mon Sep 17 00:00:00 2001
From: P <81023255+zestyoreo@users.noreply.github.com>
Date: Fri, 22 Oct 2021 15:40:37 +0530
Subject: [PATCH 5/5] math.floor update
---
.DS_Store | Bin 0 -> 6148 bytes
200050103/__pycache__/people.cpython-37.pyc | Bin 0 -> 3697 bytes
200050103/simulation.py | 3 ++-
3 files changed, 2 insertions(+), 1 deletion(-)
create mode 100644 .DS_Store
create mode 100644 200050103/__pycache__/people.cpython-37.pyc
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..3efff8e34ee08d55bc04f64ec068434c95b3dc01
GIT binary patch
literal 6148
zcmeHKyN=U96upxTV6%#dv`D)Rk}2p`QC?(4ffPcvNP&bff&x(1j-yQ^$73Z9(Gr4E
z&{0rB!zb_&RD1xU=P#(>%wr)Buas)VqPfw`xt_Ua9>?RE3=y%$I4BY2iO50{n7xWD
z#YDYGYnIU^IUtj5+@>OxkSeWkE!q?q1&jj!ngZh6wW*A6R{R#eU*7RU?xPl4L*^T>
z@JpJUKnla3jAG6B>c?S!loX5KS!OGH>GBoJwkX7d-Td*k_UZkXduK%k8%D;xO?rOm4x^Aq$LLMWY@6En#dJa)@{oGe6(y~3
z@fDL8+wv=p5y!y`fd#=|X0RJ8j2*=MWwhm@3b3dSC2)1(K$
z0u3lw>G$0VBS$0ZBW{e5dX&KD6s7f*5sEC%aW|E@;mFy~mDcchu}m*}Yx`mi+lEl>B;waujl7>1*IKaBbxk8k{%pUSOqkhiC
literal 0
HcmV?d00001
diff --git a/200050103/__pycache__/people.cpython-37.pyc b/200050103/__pycache__/people.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..0b417ca2a694397ab03f201d5dd3e38776674941
GIT binary patch
literal 3697
zcmb_fJ!~9B6yDjt+dbc%9pd~!2vm>@Bz6)Yk%(~q6e59+NQUN`)p}>`Tj&0m-9xr@
zsS**1iWVxnOhZpW4_z9Xts+H2a!*CY_ul^8of9WQVov*J-puUVH}8G#y}6t9dR0UF
z?UeHWY-rkZVv1&Ba2-$l35e9B=xXh(7i}T+w*I*$4QW2or1?;98{jNygR?{9q0u&_
zSk;=9eY~r+_I1#JhDD=^>v-bZAfX0w#_|!sb55vK*8wLU*sZnp>xrHZ|AX1DqPm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BfF1q_M{}TcTjy7Z1c(sIU1gD@Q_sAe&{_{d2|Y48AHe
z_;PqJ@U`od+0C7lLardu0-{nmP;weQPmBBB-vxRA8aK<@WXsf6eqRoHX@&ZzpJZ19
zh6;m*@xm!m&x&g$9t8nzep3O@SAn@;&>MQ0C0EH_8E^m^{kSjzo&`Mv(9V&<=;i(y
zgO}L(bL-1)
zWtZ`SqO_= rnd.randint(8, 8+person.laziness*4) or hours <= 17): #Depending on how lazy the person is, it decides when the person starts his day
+ if(hours >= rnd.randint(8, 8+math.floor(person.laziness)*4) or hours <= 17): #Depending on how lazy the person is, it decides when the person starts his day
## Randomly choosing between study, hobby and relax according to their weights defined earlier