Skip to content

Commit bb65240

Browse files
Courssumm02Courssumm02
authored andcommitted
m6 2
1 parent 8c5b112 commit bb65240

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

Module Extra 6/app.js

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
function main(){
22

3-
const N_CLONES = 40**2
3+
const N_CLONES = 45**2
44
const N_GEN = 50000
5-
const infect_rate = 0.00005
5+
const infect_rate = 0.0002
66
const initial_infection_rate = 0.001
7-
const transmission_rate = 0.6
8-
const infected_time = 5
9-
const post_time=30
10-
const D = 1
7+
const transmission_rate = 0.7
8+
const vaccine_transmission_rate = 0.01
9+
const vaccine_taking_rate = 0.00003
10+
const double_days = 4
11+
const infected_time = 10
12+
const post_time=13
13+
const vaccine_shield_days = 360
14+
const D = 3
1115
const gridx = Math.round(Math.sqrt(N_CLONES)) * Math.round(Math.sqrt(N_CLONES))==N_CLONES?Math.round(Math.sqrt(N_CLONES)) : Math.round(Math.sqrt(N_CLONES))+1
1216
const gridy = Math.round(Math.sqrt(N_CLONES)) * Math.round(Math.sqrt(N_CLONES))==N_CLONES?Math.round(Math.sqrt(N_CLONES)) : Math.round(Math.sqrt(N_CLONES))+1
1317

@@ -25,9 +29,14 @@ function main(){
2529
if (Math.random() < initial_infection_rate){
2630
grid[i].type = "infected"
2731
grid[i].infected_time = 0
32+
grid[i].vaccine_days=0
33+
grid[i].double_days=0
2834
}else{
2935
grid[i].type = "neutral"
3036
grid[i].infected_time = 0
37+
grid[i].vaccine_days=0
38+
grid[i].double_days=0
39+
3140
}
3241
}
3342
function getRandomInt(min, max) {
@@ -66,6 +75,20 @@ function main(){
6675
if (your_mate.type == "infected" && you.type=="neutral" && Math.random() < transmission_rate){
6776
you.type = "infected"
6877
}
78+
// if (your_mate.type == "infected" && you.type=="infected"){
79+
// you.type = "double"
80+
// }
81+
// TODo
82+
if (you.type=="double"){
83+
you.double_days++
84+
if (you.double_days==double_days){
85+
you.type="unneutral"
86+
you.double_days=0
87+
}
88+
}
89+
if (your_mate.type == "infected" && you.type=="vaccine" && Math.random() < vaccine_transmission_rate){
90+
you.type = "infected"
91+
}
6992
if (Math.random() < infect_rate && you.type == "unneutral"){
7093
you.type = "infected"
7194
}
@@ -86,6 +109,18 @@ function main(){
86109
you.infected_time=0
87110
}
88111
}
112+
if (Math.random() < vaccine_taking_rate){
113+
you.type = "vaccine"
114+
you.infected_time=0
115+
}
116+
if (you.type == "vaccine"){
117+
you.vaccine_days++
118+
}
119+
if (you.vaccine_days == vaccine_shield_days){
120+
you.type = "neutral"
121+
you.vaccine_days=0
122+
you.infected_time=0
123+
}
89124
new_grid.push(you)
90125

91126
}
@@ -110,6 +145,12 @@ function main(){
110145
if (el.type=="unneutral"){
111146
row.push("unneutral")
112147
}
148+
if (el.type=="vaccine"){
149+
row.push("vaccine")
150+
}
151+
if (el.type=="double"){
152+
row.push("double")
153+
}
113154

114155
}
115156
visual.push(row)

Module Extra 6/main.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ <h2>Tech used projects</h2>
3838
<input type="number" name="a1" id="a1" placeholder="0.5" value="0.3" step="0.0001">
3939
</form> -->
4040
<!-- <button type="button" onclick="app();">Run Simulation</button> -->
41-
<script src="util.js"></script>
42-
COLORS: a1a1: white; a1a2: blue; a2a2: brown; empty: green
43-
<canvas id="myChart"></canvas>
41+
<script src="util.js"></script> <canvas id="myChart"></canvas>
4442
<h3 id="day_count">s</h3>
4543
<script src="app.js"></script>
4644
</body>

Module Extra 6/util.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)