-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoal-setting.nls
More file actions
75 lines (65 loc) · 4.9 KB
/
Goal-setting.nls
File metadata and controls
75 lines (65 loc) · 4.9 KB
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
to-report preferredexit ; reports which exit should be the goal for a person
ifelse visited? = false
[report listed-visible-exits]
[report listed-exits] ;the logic is that people with previous acquaintance with the bar will know where the exits are
end
to-report listed-exits
let prioritized-exits sort-on [exit-heuristic] exits ; the exits with the lowest score - closest, least on fire - will be first
report item 0 prioritized-exits
end
to-report listed-visible-exits ; same as listed-exits but only with noted exits
let prioritized-exits sort-on [exit-heuristic] turtle-set noted-exits
report item 0 prioritized-exits
end
to-report exit-heuristic
let local-fh sum [fh] of patches in-radius danger-sensitivity ; adjustable variable to determine how sensitive people are to danger and crowdedness at exits
report distance myself + local-fh + appeal ; measures distance, manual appeal, and relative danger of the exit
end
to-report closestvisible ; selects closest visible exit
let seen sort-by [distance myself] noted-exits
report item 0 seen ;if they can see an exit (including the main exit) they will head towards the closest, otherwise they will go towards the main exit, which everyone noted
end
to-report closest ; selects closest exit regardless of visibility
report (min-one-of exits [distance myself])
end
to preferreddirection ; sets the goal for a person, either the person or exit
ifelse (distance min-one-of exits [distance myself] < 1 ) ; if someone is within a tenth of a meter of an exit they leave via that exit
[exit-building]
; calls preferredexit, closest, closestvisible, and leader-follower functions
[ ifelse any? link-neighbors = false ; sets the condition that if they came alone, ended up alone through losing their loved ones or deciding to no longer prioritize them then they go towards their preferred exit
[set goal preferredexit] ; selects either closest or closest visible exit depending on visit history
[ ifelse (distance min-one-of link-neighbors [distance myself] <= (20 * scale-modifier) ) ; if they have loved ones they have not given up on, they go towards them
[leader-follower] ; but if they are within two meters of their loved ones they switch to leader-follower behavior to work as a group
[set goal min-one-of link-neighbors [distance myself]] ; people move towards their closest loved one
]]
;set goals-over-time lput goal goals-over-time
end
to set-leadership-quality ; the traits the determine who the most likely leader is
set leadership-quality 0 + random-float 1 ; every time leadership has to be re-run they start fresh, with a small randomized element to ensure different scores when there would otherwise be ties
if visited? = true [set leadership-quality leadership-quality + 1] ; people who have visited before will be not only more knowledgeable but known to be so
if gender = "male" [set leadership-quality leadership-quality + 1] ;male gender, based on Enarson
; if (visited? = false) and (length noted-exits > 1) [set leadership-quality leadership-quality + 1] ; people who have noticed more exits than the crowded main exit will be more confident and able to lead in other directions
if group-number = 300 [set leadership-quality leadership-quality + 1] ; the 300 group is for employees
if energy < 50 [set leadership-quality leadership-quality - 1]; people with substantial injury are less likely to be leaders
;waiting to hear back about other factors
end
to-report close-group
report turtle-set list (link-neighbors with [distance myself <= (20 * scale-modifier)]) (self)
; defines close groups as people with the same group number who are within 2 m
end
to set-leadership ; designates a group leader within a small group
ask close-group
[set-leadership-quality ; for every leadership factor that applies, people receive one point
if leader = true [set leadership-quality (leadership-quality * 2) ] ; if someone is already the leader, their score is doubled
]
ask close-group with-max [leadership-quality] [set leader true]
end
to leader-follower ; designates a group leader within a small group and then sets subsequent behavior
set-leadership
let group-leader close-group with [leader = true] ; defines who the leader is
; the person with the highest leadership quality is made the leader
ask group-leader [ifelse ((goal = nobody) or (all? link-neighbors [distance myself <= (20 * scale-modifier)])) = true; the leader selects the next goal. if the other people they were looking for are removed from simulation or all group members are within 2m, sets the goal for their preferred exit
[set goal preferredexit]
[set goal min-one-of link-neighbors with [distance myself > (20 * scale-modifier)] [distance myself]]] ; aims for the closest group member who is outside the 2m radius
ask close-group with [leader != true] [set goal one-of group-leader] ; other group members aim to follow the leader rather than set individual goals
end