-
Notifications
You must be signed in to change notification settings - Fork 5
/
crowd_evacuation.nlogo
1734 lines (1586 loc) · 44.9 KB
/
crowd_evacuation.nlogo
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
globals [
blue-escapees
cyan-escapees
yellow-escapees
red-escapees
beige-escapees
green-escapees
blue-fire-deaths
cyan-fire-deaths
yellow-fire-deaths
red-fire-deaths
beige-fire-deaths
green-fire-deaths
blue-stampede-deaths
cyan-stampede-deaths
yellow-stampede-deaths
red-stampede-deaths
beige-stampede-deaths
green-stampede-deaths
female-escapees
female-fire-deaths
female-stampede-deaths
male-escapees
male-fire-deaths
male-stampede-deaths
child-escapees
child-fire-deaths
child-stampede-deaths
adult-escapees
adult-fire-deaths
adult-stampede-deaths
elderly-escapees
elderly-fire-deaths
elderly-stampede-deaths
oldgoal
]
breed [survivors survivor]
breed[doors door]
patches-own [
distance1
distance2
distance3
distance4
distance5
distance6
distance7
distance8
distance9
distance10
distancefire
]
survivors-own [
goal
health
base-speed
speed ; impacted by status and patch pressure (sum surrounding patch pressure)
vision
gender
age
mass
panic
; reaction-time
; collaboration
; insistence
knowledge
]
to setup
ca
setup-stadium
;create 10 exits
let door-xlist [-127 -87 -70 -49 -33 27 44 65 82 122]
(foreach door-xlist[ [x] ->
create-doors 1 [setxy x 21 set shape "square" set color lime set heading 180 set size 2]
])
ask patches [set distance1 [distance myself] of door 14178]
ask patches [set distance2 [distance myself] of door 14179]
ask patches [set distance3 [distance myself] of door 14180]
ask patches [set distance4 [distance myself] of door 14181]
ask patches [set distance5 [distance myself] of door 14182]
ask patches [set distance6 [distance myself] of door 14183]
ask patches [set distance7 [distance myself] of door 14184]
ask patches [set distance8 [distance myself] of door 14185]
ask patches [set distance9 [distance myself] of door 14186]
ask patches [set distance10 [distance myself] of door 14187]
;set goal
ask survivors[
set goal min-one-of doors [distance myself]
]
set-survivors-attributes
; Start fire
let origin patch 0 135
if random-fire? [
set origin patch random-xcor random-ycor
while [ [ pcolor ] of origin = black ] [
set origin one-of patches
]
]
ask origin [
draw-rectangle pxcor pycor 5 5 orange
]
ask patches [set distancefire distancexy 0 135]
reset-ticks
end
to go
spread-fire
;ask patches [set distancefire min [distance myself] of patches with [pcolor = orange]]
if use-panic? [
ask survivors [
if is-patch? patch-at-heading-and-distance (180 + heading) vision [
if [pcolor] of patch-ahead vision = orange or [pcolor] of patch-at-heading-and-distance (180 + heading) vision = orange [
set panic 2
set speed 1.8056 ; 6.5km/h = 1.8056m/s
]
]
if is-patch? patch-at-heading-and-distance (180 + heading) (vision / 2) [
if [pcolor] of patch-ahead (vision / 2) = orange or [pcolor] of patch-at-heading-and-distance (180 + heading) (vision / 2) = orange [
set panic 3
set speed 2.5 ; 9km/h = 2.5m/s
]
]
; set speed base-speed * panic
]
]
ifelse behaviour = "smart"
[ move-normal ]
[ follow-crowd ]
; Compute force exerted by survivors on each patch
ask survivors [
if compute-force patch-here >= health [
ifelse color = blue
[ set blue-stampede-deaths blue-stampede-deaths + 1]
[ ifelse color = cyan
[ set cyan-stampede-deaths cyan-stampede-deaths + 1 ]
[ ifelse color = yellow
[ set yellow-stampede-deaths yellow-stampede-deaths + 1 ]
[ ifelse color = red
[ set red-stampede-deaths red-stampede-deaths + 1 ]
[ ifelse color = 29
[ set beige-stampede-deaths beige-stampede-deaths + 1 ]
[ set green-stampede-deaths green-stampede-deaths + 1 ]
]
]
]
]
ifelse gender = "female"
[ set female-stampede-deaths female-stampede-deaths + 1 ]
[ set male-stampede-deaths male-stampede-deaths + 1 ]
ifelse age = "child"
[ set child-stampede-deaths child-stampede-deaths + 1 ]
[ ifelse age = "adult"
[ set adult-stampede-deaths adult-stampede-deaths + 1 ]
[ set elderly-stampede-deaths elderly-stampede-deaths + 1 ]
]
die
]
]
tick
end
to-report compute-force [ p ]
; Force exerted by survivors in the patch
; acceleration = (vFinal−vInitial)/(tFinal−tInitial)
; Force = mass x acceleration
let force 0
ask survivors-on p [
set force force + mass * speed
]
report force
end
to spread-fire
; Fire expands every 2 seconds
if ticks mod 10 = 0 [
ask patches with [ pcolor = orange ] [
ask neighbors with [ pcolor != black ] [
set pcolor orange
]
]
]
ask survivors [
;; Kill survivors on patches which have caught fire
if [ pcolor ] of patch-here = orange [
ifelse color = blue
[ set blue-fire-deaths blue-fire-deaths + 1]
[ ifelse color = cyan
[ set cyan-fire-deaths cyan-fire-deaths + 1 ]
[ ifelse color = yellow
[ set yellow-fire-deaths yellow-fire-deaths + 1 ]
[ ifelse color = red
[ set red-fire-deaths red-fire-deaths + 1 ]
[ ifelse color = 29
[ set beige-fire-deaths beige-fire-deaths + 1 ]
[ set green-fire-deaths green-fire-deaths + 1 ]
]
]
]
]
ifelse gender = "female"
[ set female-fire-deaths female-fire-deaths + 1 ]
[ set male-fire-deaths male-fire-deaths + 1 ]
ifelse age = "child"
[ set child-fire-deaths child-fire-deaths + 1 ]
[ ifelse age = "adult"
[ set adult-fire-deaths adult-fire-deaths + 1 ]
[ set elderly-fire-deaths elderly-fire-deaths + 1 ]
]
die
]
]
;; kill exit door
set oldgoal FALSE
ask doors [
if [ pcolor ] of patch-here = orange [set oldgoal true
die ]
]
; let shortest 0
ask survivors [ set goal min-one-of doors [distance myself]
]
end
to move-normal
ask survivors [
let next-patch 0
ifelse goal = door 14178 [set next-patch min-one-of neighbors [distance1]] [
ifelse goal = door 14179 [set next-patch min-one-of neighbors [distance2]] [
ifelse goal = door 14180 [set next-patch min-one-of neighbors [distance3]] [
ifelse goal = door 14181 [set next-patch min-one-of neighbors [distance4]] [
ifelse goal = door 14182 [set next-patch min-one-of neighbors [distance5]] [
ifelse goal = door 14183 [set next-patch min-one-of neighbors [distance6]] [
ifelse goal = door 14184 [set next-patch min-one-of neighbors [distance7]] [
ifelse goal = door 14185 [set next-patch min-one-of neighbors [distance8]] [
ifelse goal = door 14186 [set next-patch min-one-of neighbors [distance9]] [
ifelse goal = door 14187 [set next-patch min-one-of neighbors [distance10]] []]]]]]]]]]
repeat speed [
while [ [pcolor] of next-patch != grey] [
ask next-patch [
set distance1 10000000
set distance2 10000000
set distance3 10000000
set distance4 10000000
set distance5 10000000
set distance6 10000000
set distance7 10000000
set distance8 10000000
set distance9 10000000
set distance10 10000000
]
ifelse goal = door 14178 [set next-patch min-one-of neighbors [distance1]] [
ifelse goal = door 14179 [set next-patch min-one-of neighbors [distance2]] [
ifelse goal = door 14180 [set next-patch min-one-of neighbors [distance3]] [
ifelse goal = door 14181 [set next-patch min-one-of neighbors [distance4]] [
ifelse goal = door 14182 [set next-patch min-one-of neighbors [distance5]] [
ifelse goal = door 14183 [set next-patch min-one-of neighbors [distance6]] [
ifelse goal = door 14184 [set next-patch min-one-of neighbors [distance7]] [
ifelse goal = door 14185 [set next-patch min-one-of neighbors [distance8]] [
ifelse goal = door 14186 [set next-patch min-one-of neighbors [distance9]] [
ifelse goal = door 14187 [set next-patch min-one-of neighbors [distance10]] []]]]]]]]]]
]
if not patch-overcrowded? next-patch [ move-to next-patch ]
]
if any? doors-here [
ifelse color = blue
[ set blue-escapees blue-escapees + 1]
[ ifelse color = cyan
[ set cyan-escapees cyan-escapees + 1 ]
[ ifelse color = yellow
[ set yellow-escapees yellow-escapees + 1 ]
[ ifelse color = red
[ set red-escapees red-escapees + 1 ]
[ ifelse color = 29
[ set beige-escapees beige-escapees + 1 ]
[ set green-escapees green-escapees + 1 ]
]
]
]
]
ifelse gender = "female"
[ set female-escapees female-escapees + 1 ]
[ set male-escapees male-escapees + 1 ]
ifelse age = "child"
[ set child-escapees child-escapees + 1 ]
[ ifelse age = "adult"
[ set adult-escapees adult-escapees + 1 ]
[ set elderly-escapees elderly-escapees + 1 ]
]
die
]
]
end
to follow-crowd
;ask patches [set distancefire distance (min-one-of patches with [pcolor = orange] [distance myself]) ]
ask survivors [
let next-patch 0
ifelse any? patches in-radius vision with [any? doors-here] [
set goal min-one-of doors [distance myself]
ifelse goal = door 14178 [set next-patch min-one-of neighbors [distance1]] [
ifelse goal = door 14179 [set next-patch min-one-of neighbors [distance2]] [
ifelse goal = door 14180 [set next-patch min-one-of neighbors [distance3]] [
ifelse goal = door 14181 [set next-patch min-one-of neighbors [distance4]] [
ifelse goal = door 14182 [set next-patch min-one-of neighbors [distance5]] [
ifelse goal = door 14183 [set next-patch min-one-of neighbors [distance6]] [
ifelse goal = door 14184 [set next-patch min-one-of neighbors [distance7]] [
ifelse goal = door 14185 [set next-patch min-one-of neighbors [distance8]] [
ifelse goal = door 14186 [set next-patch min-one-of neighbors [distance9]] [
ifelse goal = door 14187 [set next-patch min-one-of neighbors [distance10]] []]]]]]]]]]
while [ [pcolor] of next-patch != grey] [
ask next-patch [
set distance1 10000000
set distance2 10000000
set distance3 10000000
set distance4 10000000
set distance5 10000000
set distance6 10000000
set distance7 10000000
set distance8 10000000
set distance9 10000000
set distance10 10000000
]
ifelse goal = door 14178 [set next-patch min-one-of neighbors [distance1]] [
ifelse goal = door 14179 [set next-patch min-one-of neighbors [distance2]] [
ifelse goal = door 14180 [set next-patch min-one-of neighbors [distance3]] [
ifelse goal = door 14181 [set next-patch min-one-of neighbors [distance4]] [
ifelse goal = door 14182 [set next-patch min-one-of neighbors [distance5]] [
ifelse goal = door 14183 [set next-patch min-one-of neighbors [distance6]] [
ifelse goal = door 14184 [set next-patch min-one-of neighbors [distance7]] [
ifelse goal = door 14185 [set next-patch min-one-of neighbors [distance8]] [
ifelse goal = door 14186 [set next-patch min-one-of neighbors [distance9]] [
ifelse goal = door 14187 [set next-patch min-one-of neighbors [distance10]] []]]]]]]]]]
]
][
ifelse is-patch? patch-at-heading-and-distance (180 + heading) vision and is-patch? patch-at-heading-and-distance (90 + heading) vision and is-patch? patch-at-heading-and-distance (270 + heading) vision [
ifelse [pcolor] of patch-ahead vision = orange or [pcolor] of patch-at-heading-and-distance (180 + heading) vision = orange or [pcolor] of patch-at-heading-and-distance (90 + heading) vision = orange or [pcolor] of patch-at-heading-and-distance (270 + heading) vision = orange [
set next-patch max-one-of neighbors [distancefire]
while [ [pcolor] of next-patch != grey] [
ask next-patch [set distancefire 0]
set next-patch max-one-of neighbors [distancefire]
]
if not patch-overcrowded? next-patch [ move-to next-patch ]
][
if any? turtles-on neighbors [
let avg mean [heading] of turtles-on neighbors
ifelse avg <= 90 [set heading 90][
ifelse avg <= 180 [set heading 180][
ifelse avg <= 270 [set heading 270][
set heading 0
]
]
]
if [pcolor] of patch-ahead 1 = gray [fd 1]
]
]
][]
]
]
end
to setup-stadium
draw-rectangle -163 135 321 105 gray
create-blue1
create-blue2
create-blue3
create-cyan1
create-cyan2
create-cyan3
create-yellow1
create-yellow2
create-yellow3
create-yellow4
create-yellow5
create-lime1
create-lime2
create-lime3
create-green1
create-green2
create-green3
draw-rectangle -250 25 500 8 gray
draw-rectangle -14 17 25 18 white ;draw center bridge
;draw-black
draw-leftbridge
draw-rightbridge
draw-rectangle -114 3 228 80 gray ;draw floating platform
create-stairs1 ;create all left-facing stairs
create-stairs2 ;create all right-facing stairs
end
to set-survivors-attributes
ask survivors [
; Set gender
ifelse random-float 1.0 < 0.4805
[ set gender "male" ]
[ set gender "female" ]
; Set age
ifelse random-float 1.0 <= 0.1498
[ set age "child" ]
[ ifelse random-float 1.0 < 0.8708
[ set age "adult" ]
[ set age "elderly" ]
]
; set age random-normal 42.4 20
; Set base speed
ifelse age = "child"
[ set base-speed 0.3889 ] ; 1.4km/h = 0.38889m/s
[ ifelse age = "adult"
[ set base-speed random-float-between 1.4778 1.5083 ] ; 5.32km/h = 1.4778m/s and 5.43km/h = 1.5083m/s
[ set base-speed random-float-between 1.2528 1.3194 ] ; 4.51km/h = 1.2528m/s and 4.75km/h = 1.3194m/s
]
set speed base-speed
; ifelse age < 15
; [ set speed 1.4 ]
; [ ifelse age < 65
; [ set speed random-float-between 5.32 5.43 ]
; [ set speed random-float-between 4.51 4.75 ]
; ]
; Set mass
ifelse age = "child"
[ ifelse gender = "male"
[ set mass random-normal 40 4]
[ set mass random-normal 35 4]
]
[ set mass random-normal 57.7 4 ]
; Set health
set health mass * speed * threshold
; show health
; Set vision
set vision random max-vision
; Set panic level
set panic 1
]
end
to-report random-float-between [ #min #max ] ; random float in given range
report #min + random-float (#max - #min)
end
to-report patch-overcrowded? [ p ]
report count turtles-on p > 10
end
to create-stairs1
let xlist create-xlist4 82
let ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist4 44
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist4 -33
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist4 -70
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist4 -127
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
end
to create-stairs2
let xlist create-xlist5 121
let ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist5 64
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist5 26
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist5 -50
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
set xlist create-xlist5 -88
set ylist create-ylist2 5 30
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 2 1 gray
])
end
to create-blue1
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -163
(foreach ylist [ [y] ->
draw-rectangle -163 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -163 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
let xlist create-xlist -163
set ylist create-ylist 17 65
let wlist create-wlist 17
(foreach xlist ylist wlist [ [x y w] ->
draw-rectangle x y w 1 blue
set peoplelist create-peoplelist w x
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
end
to create-blue2
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -144
(foreach ylist [ [y] ->
draw-rectangle -144 y 17 1 blue
;(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -144 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -144 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
end
to create-blue3
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -125
(foreach ylist [ [y] ->
draw-rectangle -125 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -125 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -125 y 17 1 blue
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color blue set heading 180]])
])
end
to create-cyan1
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -106
(foreach ylist [ [y] ->
draw-rectangle -106 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -106 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -106 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
end
to create-cyan2
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -87
(foreach ylist [ [y] ->
draw-rectangle -87 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -87 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -87 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
end
to create-cyan3
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -68
(foreach ylist [ [y] ->
draw-rectangle -68 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -68 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -68 y 17 1 cyan
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color cyan set heading 180]])
])
end
to create-yellow1
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -49
(foreach ylist [ [y] ->
draw-rectangle -49 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -49 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -49 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
end
to create-yellow2
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -30
(foreach ylist [ [y] ->
draw-rectangle -30 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -30 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -30 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
end
to create-yellow3
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 -11
(foreach ylist [ [y] ->
draw-rectangle -11 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle -11 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle -11 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
end
to create-yellow4
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 8
(foreach ylist [ [y] ->
draw-rectangle 8 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 8 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 8 y 17 1 red
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color red set heading 180]])
])
end
to create-yellow5
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 27
(foreach ylist [ [y] ->
draw-rectangle 27 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 27 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 27 y 17 1 yellow
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color yellow set heading 180]])
])
end
to create-lime1
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 46
(foreach ylist [ [y] ->
draw-rectangle 46 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 46 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 46 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
end
to create-lime2
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 65
(foreach ylist [ [y] ->
draw-rectangle 65 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 65 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 65 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
end
to create-lime3
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 84
(foreach ylist [ [y] ->
draw-rectangle 84 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 84 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 84 y 17 1 29
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color 29 set heading 180]])
])
end
to create-green1
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 103
(foreach ylist [ [y] ->
draw-rectangle 103 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 103 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 103 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
end
to create-green2
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 122
(foreach ylist [ [y] ->
draw-rectangle 122 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 122 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 65
(foreach ylist [ [y] ->
draw-rectangle 122 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
end
to create-green3
let ylist create-ylist 17 135
let peoplelist create-peoplelist 17 141
(foreach ylist [ [y] ->
draw-rectangle 141 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 100
(foreach ylist [ [y] ->
draw-rectangle 141 y 17 1 green
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
set ylist create-ylist 17 65
let wlist create-wlist 17
(foreach ylist wlist [ [y w] ->
draw-rectangle 141 y w 1 green
set peoplelist create-peoplelist w 141
(foreach peoplelist [ [ppl] -> create-survivors 1 [setxy ppl y set color green set heading 180]])
])
end
to-report create-xlist5 [input]
report n-values (5) [ [i] -> input - i * 1]
end
to-report create-xlist4 [input]
report n-values (5) [ [i] -> input + i * 1]
end
to-report create-xlist3 [input]
report n-values (14) [ [i] -> input - i * 1]
end
to-report create-xlist2 [input]
report n-values (14) [ [i] -> input + i * 1]
end
to-report create-ylist2 [input1 input2]
report n-values (input1) [ [i] -> input2 - i * 1]
end
to-report create-xlist [input]
report n-values (17) [ [i] -> input + i * 1]
end
to-report create-ylist [input1 input2]
report n-values (input1) [ [i] -> input2 - i * 2]
end
to-report create-wlist [input]
report n-values (17) [ [i] -> input - i * 1]
end
to-report create-peoplelist [input1 input2]
report n-values (input1) [ [i] -> input2 + i]
end
to draw-rectangle [ x y w l c ]
ask patches with
[ w + x > pxcor and pxcor >= x
and
y >= pycor and pycor > (y - l) ] [ set pcolor c ]
end
to draw-leftbridge
let xlist create-xlist2 -120
let ylist create-ylist2 14 17
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 17 1 white
])
end
to draw-rightbridge
let xlist create-xlist3 94
let ylist create-ylist2 14 17
(foreach xlist ylist [ [x y] ->
draw-rectangle x y 17 1 white
])
end
@#$#@#$#@
GRAPHICS-WINDOW
261
10
1581
1062
-1
-1
3.85
1
10
1
1
1
0
0
0
1
-170
170
-135
135
1
1
1
ticks
1.0
BUTTON
4
450
70
483
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
75
450
138
483
NIL
go
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
4
139
116
184
No. of survivors
count survivors
17
1
11
CHOOSER
3
46
141
91
behaviour
behaviour
"smart" "follow"
0
MONITOR
3
189
104
234
Total Escapees
blue-escapees + cyan-escapees + yellow-escapees + red-escapees + beige-escapees + green-escapees
17
1