-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.txt
46 lines (34 loc) · 1.17 KB
/
config.txt
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
// Code for Blink simulation on iPad
// ------------------------------------
// Simple Configure Cell Function
// ------------------------------------
var vacThreshold = 0.999
public func configureCell(cell: Cell) {
let threshold = 1.0 - 0.1 * Double(cell.numberOfAliveNeighbors)
switch cell.state {
case .alive:
// Cell has virus
cell.state = .alive
case .dead:
// Case is used to represent cells that have been vaccinated
cell.state = .dead
case .idle:
let vacRandom = Double.random(in: 0.0 ... 1.0)
if vacRandom > vacThreshold {
cell.state = .dead
}
// Cell does NOT have virus
let random = Double.random(in: 0.0 ... 1.0)
if random > threshold {
if cell.state != .dead {
cell.state = .alive
}
}
let randomTraveler = Double.random(in: 0.0 ... 1.0)
// Make 0.9999 below be a threshold constant
if randomTraveler > 0.9999 {
cell.state = .alive
}
}
vacThreshold -= 0.0000001
}