-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainv1.nlogo
1935 lines (1703 loc) · 60.4 KB
/
mainv1.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
breed [ prepareds prepared ]
breed [ listeners listener ]
breed [ helpers helper ]
breed [ fighters fighter ]
globals [
prepared-deaths
listener-deaths
helper-deaths
fighter-deaths
prepared-evacuated
listener-evacuated
helper-evacuated
fighter-evacuated
ave-age-at-death
ave-age-at-evac
fire-count
]
patches-own [
floor-number-patch
fire-extinguisher
]
turtles-own [
delay
floor-number-turtle
speed
age
]
prepareds-own [
nearest-exit
]
listeners-own [
nearest-visible-exit
is-alerted
]
helpers-own [
assigned-exit
]
fighters-own [
nearest-exit
has-extinguisher
extinguisher-amount
]
to setup
clear-all
setup-floors
setup-people
setup-fire
set prepared-deaths 0
set listener-deaths 0
set helper-deaths 0
set fighter-deaths 0
set prepared-evacuated 0
set listener-evacuated 0
set helper-evacuated 0
set fighter-evacuated 0
set ave-age-at-death 0
set ave-age-at-evac 0
set fire-count 1
reset-ticks
end
to setup-floors
ask patches [
set floor-number-patch 0
; VIP
if pxcor <= 28 and pxcor >= -28 and pycor >= -22 and pycor <= 22
[ set pcolor sky ]
if pxcor = 29 or pxcor = -29 or pxcor = 30 or pxcor = -30 and pycor >= -21 and pycor <= 21
[ set pcolor sky ]
if pxcor = 31 or pxcor = -31 or pxcor = 32 or pxcor = -32 and pycor >= -20 and pycor <= 20
[ set pcolor sky ]
if pxcor = 33 or pxcor = -33 or pxcor = 34 or pxcor = -34 and pycor >= -19 and pycor <= 19
[ set pcolor sky ]
if pxcor = 35 or pxcor = -35 or pxcor = 36 or pxcor = -36 and pycor >= -18 and pycor <= 18
[ set pcolor sky ]
if pxcor = 37 or pxcor = -37 or pxcor = 38 or pxcor = -38 and pycor >= -17 and pycor <= 17
[ set pcolor sky ]
if pxcor = 39 or pxcor = -39 or pxcor = 40 or pxcor = -40 and pycor >= -16 and pycor <= 16
[ set pcolor sky ]
if pxcor = 41 or pxcor = -41 and pycor >= -15 and pycor <= 15
[ set pcolor sky ]
if abs pxcor >= 33 and abs pxcor <= 36 and abs pycor >= 19 and abs pycor <= 20
[ set pcolor sky ]
; 211, 201, 212, 202
if abs pxcor >= 43 and abs pxcor <= 49 and abs pycor >= 1 and abs pycor <= 12
[ set pcolor blue ]
; 411, 401, 412, 402
if abs pxcor >= 53 and abs pxcor <= 62 and abs pycor >= 1 and abs pycor <= 13
[ set pcolor magenta ]
; 511, 501, 512, 502
if abs pxcor >= 64 and abs pxcor <= 71 and abs pycor >= 1 and abs pycor <= 13
[ set pcolor pink ]
; 206, 217
if pxcor >= -6 and pxcor <= 6 and abs pycor >= 24 and abs pycor <= 40
[ set pcolor blue ]
; 406, 417
if pxcor >= -6 and pxcor <= 6 and abs pycor >= 44 and abs pycor <= 54
[ set pcolor magenta ]
; 506, 517
if pxcor >= -6 and pxcor <= 6 and abs pycor >= 57 and abs pycor <= 62
[ set pcolor pink ]
; 207, 205, 216, 218
if abs pxcor >= 9 and abs pxcor <= 21 and abs pycor >= 24 and abs pycor <= 40
[ set pcolor blue ]
; 407, 405, 416, 418
if abs pxcor >= 9 and abs pxcor <= 21 and abs pycor >= 44 and abs pycor <= 54
[ set pcolor magenta ]
; 507, 505, 516, 518
if abs pxcor >= 9 and abs pxcor <= 21 and abs pycor >= 57 and abs pycor <= 62
[ set pcolor pink ]
; 208, 204, 215, 219
if abs pxcor >= 24 and abs pxcor <= 27 and abs pycor >= 24 and abs pycor <= 40
[ set pcolor blue ]
if abs pxcor = 28 and abs pycor >= 25 and abs pycor <= 40
[ set pcolor blue ]
if abs pxcor = 29 and abs pycor >= 26 and abs pycor <= 40
[ set pcolor blue ]
if abs pxcor = 30 and abs pycor >= 28 and abs pycor <= 39
[ set pcolor blue ]
if abs pxcor = 31 and abs pycor >= 30 and abs pycor <= 39
[ set pcolor blue ]
if abs pxcor = 32 and abs pycor >= 32 and abs pycor <= 39
[ set pcolor blue ]
if abs pxcor = 33 and abs pycor >= 34 and abs pycor <= 39
[ set pcolor blue ]
if abs pxcor = 34 and abs pycor >= 36 and abs pycor <= 39
[ set pcolor blue ]
if abs pxcor = 35 and abs pycor >= 38 and abs pycor <= 39
[ set pcolor blue ]
; 209, 203, 204, 220
if abs pxcor = 30 and abs pycor >= 23 and abs pycor <= 24
[ set pcolor blue ]
if abs pxcor = 31 and abs pycor >= 23 and abs pycor <= 26
[ set pcolor blue ]
if abs pxcor = 32 and abs pycor >= 22 and abs pycor <= 28
[ set pcolor blue ]
if abs pxcor = 33 and abs pycor >= 22 and abs pycor <= 30
[ set pcolor blue ]
if abs pxcor = 34 and abs pycor >= 22 and abs pycor <= 32
[ set pcolor blue ]
if abs pxcor = 35 and abs pycor >= 22 and abs pycor <= 34
[ set pcolor blue ]
if abs pxcor = 36 and abs pycor >= 23 and abs pycor <= 36
[ set pcolor blue ]
if abs pxcor = 37 and abs pycor >= 23 and abs pycor <= 37
[ set pcolor blue ]
if abs pxcor = 38 and abs pycor >= 24 and abs pycor <= 37
[ set pcolor blue ]
if abs pxcor = 39 and abs pycor >= 24 and abs pycor <= 36
[ set pcolor blue ]
if abs pxcor = 40 and abs pycor >= 25 and abs pycor <= 35
[ set pcolor blue ]
if abs pxcor = 41 and abs pycor >= 25 and abs pycor <= 34
[ set pcolor blue ]
if abs pxcor = 42 and abs pycor >= 26 and abs pycor <= 33
[ set pcolor blue ]
if abs pxcor = 43 and abs pycor >= 26 and abs pycor <= 32
[ set pcolor blue ]
if abs pxcor = 44 and abs pycor >= 27 and abs pycor <= 31
[ set pcolor blue ]
if abs pxcor = 45 and abs pycor >= 27 and abs pycor <= 30
[ set pcolor blue ]
if abs pxcor = 46 and abs pycor >= 28 and abs pycor <= 29
[ set pcolor blue ]
; 210, 202, 213, 221
if abs pxcor = 39 and abs pycor >= 19 and abs pycor <= 22
[ set pcolor blue ]
if abs pxcor = 40 and abs pycor >= 18 and abs pycor <= 22
[ set pcolor blue ]
if abs pxcor = 41 and abs pycor >= 18 and abs pycor <= 23
[ set pcolor blue ]
if abs pxcor = 42 and abs pycor >= 17 and abs pycor <= 23
[ set pcolor blue ]
if abs pxcor >= 43 and abs pxcor <= 44 and abs pycor >= 14 and abs pycor <= 24
[ set pcolor blue ]
if abs pxcor >= 45 and abs pxcor <= 46 and abs pycor >= 14 and abs pycor <= 25
[ set pcolor blue ]
if abs pxcor >= 47 and abs pxcor <= 48 and abs pycor >= 14 and abs pycor <= 26
[ set pcolor blue ]
if abs pxcor = 49 and abs pycor >= 14 and abs pycor <= 23
[ set pcolor blue ]
; 408, 404, 415, 419
if abs pxcor >= 24 and abs pxcor <= 29 and abs pycor >= 44 and abs pycor <= 54
[ set pcolor magenta ]
if abs pxcor >= 30 and abs pxcor <= 36 and abs pycor >= 43 and abs pycor <= 53
[ set pcolor magenta ]
if abs pxcor = 37 and abs pycor >= 45 and abs pycor <= 52
[ set pcolor magenta ]
if abs pxcor = 38 and abs pycor >= 47 and abs pycor <= 52
[ set pcolor magenta ]
if abs pxcor = 39 and abs pycor >= 49 and abs pycor <= 52
[ set pcolor magenta ]
if abs pxcor = 40 and abs pycor >= 51 and abs pycor <= 52
[ set pcolor magenta ]
; 508, 504, 515, 519
if abs pxcor >= 24 and abs pxcor <= 30 and abs pycor >= 57 and abs pycor <= 62
[ set pcolor pink ]
if abs pxcor >= 31 and abs pxcor <= 37 and abs pycor >= 56 and abs pycor <= 62
[ set pcolor pink ]
if abs pxcor >= 38 and abs pxcor <= 41 and abs pycor >= 55 and abs pycor <= 62
[ set pcolor pink ]
if abs pxcor = 42 and abs pycor >= 57 and abs pycor <= 62
[ set pcolor pink ]
if abs pxcor = 43 and abs pycor >= 60 and abs pycor <= 62
[ set pcolor pink ]
if abs pxcor = 44 and abs pycor = 62
[ set pcolor pink ]
; 409A, 403B, 414B, 420A
if abs pxcor = 38 and abs pycor >= 42 and abs pycor <= 43
[ set pcolor magenta ]
if abs pxcor = 39 and abs pycor >= 41 and abs pycor <= 45
[ set pcolor magenta ]
if abs pxcor = 40 and abs pycor >= 40 and abs pycor <= 47
[ set pcolor magenta ]
if abs pxcor = 41 and abs pycor >= 39 and abs pycor <= 49
[ set pcolor magenta ]
if abs pxcor = 42 and abs pycor >= 38 and abs pycor <= 51
[ set pcolor magenta ]
if abs pxcor = 43 and abs pycor >= 37 and abs pycor <= 51
[ set pcolor magenta ]
if abs pxcor = 44 and abs pycor >= 36 and abs pycor <= 50
[ set pcolor magenta ]
if abs pxcor = 45 and abs pycor >= 37 and abs pycor <= 49
[ set pcolor magenta ]
if abs pxcor = 46 and abs pycor >= 38 and abs pycor <= 48
[ set pcolor magenta ]
if abs pxcor = 47 and abs pycor >= 39 and abs pycor <= 47
[ set pcolor magenta ]
if abs pxcor = 48 and abs pycor >= 40 and abs pycor <= 46
[ set pcolor magenta ]
if abs pxcor = 49 and abs pycor >= 41 and abs pycor <= 45
[ set pcolor magenta ]
if abs pxcor = 50 and abs pycor >= 42 and abs pycor <= 44
[ set pcolor magenta ]
if abs pxcor = 51 and abs pycor = 43
[ set pcolor magenta ]
; 409B, 403A, 414A, 420B
if abs pxcor = 46 and abs pycor >= 34 and abs pycor <= 35
[ set pcolor magenta ]
if abs pxcor = 47 and abs pycor >= 33 and abs pycor <= 36
[ set pcolor magenta ]
if abs pxcor = 48 and abs pycor >= 32 and abs pycor <= 37
[ set pcolor magenta ]
if abs pxcor = 49 and abs pycor >= 31 and abs pycor <= 38
[ set pcolor magenta ]
if abs pxcor = 50 and abs pycor >= 30 and abs pycor <= 39
[ set pcolor magenta ]
if abs pxcor = 51 and abs pycor >= 29 and abs pycor <= 40
[ set pcolor magenta ]
if abs pxcor = 52 and abs pycor >= 29 and abs pycor <= 41
[ set pcolor magenta ]
if abs pxcor = 53 and abs pycor >= 30 and abs pycor <= 41
[ set pcolor magenta ]
if abs pxcor = 54 and abs pycor >= 30 and abs pycor <= 40
[ set pcolor magenta ]
if abs pxcor = 55 and abs pycor >= 31 and abs pycor <= 39
[ set pcolor magenta ]
if abs pxcor = 56 and abs pycor >= 31 and abs pycor <= 38
[ set pcolor magenta ]
if abs pxcor = 57 and abs pycor >= 32 and abs pycor <= 37
[ set pcolor magenta ]
if abs pxcor = 58 and abs pycor >= 32 and abs pycor <= 36
[ set pcolor magenta ]
if abs pxcor = 59 and abs pycor >= 33 and abs pycor <= 35
[ set pcolor magenta ]
if abs pxcor = 60 and abs pycor >= 33 and abs pycor <= 34
[ set pcolor magenta ]
; 410, 402, 413, 421
if abs pxcor = 52 and abs pycor >= 23 and abs pycor <= 27
[ set pcolor magenta ]
if abs pxcor = 53 and abs pycor >= 15 and abs pycor <= 27
[ set pcolor magenta ]
if abs pxcor >= 54 and abs pxcor <= 55 and abs pycor >= 15 and abs pycor <= 28
[ set pcolor magenta ]
if abs pxcor >= 56 and abs pxcor <= 57 and abs pycor >= 15 and abs pycor <= 29
[ set pcolor magenta ]
if abs pxcor >= 58 and abs pxcor <= 59 and abs pycor >= 15 and abs pycor <= 30
[ set pcolor magenta ]
if abs pxcor >= 60 and abs pxcor <= 61 and abs pycor >= 15 and abs pycor <= 31
[ set pcolor magenta ]
if abs pxcor = 62 and abs pycor >= 15 and abs pycor <= 22
[ set pcolor magenta ]
; 509A, 503B, 514B, 520A
if abs pxcor = 43 and abs pycor = 55
[ set pcolor pink ]
if abs pxcor = 44 and abs pycor >= 54 and abs pycor <= 58
[ set pcolor pink ]
if abs pxcor = 45 and abs pycor >= 53 and abs pycor <= 60
[ set pcolor pink ]
if abs pxcor = 46 and abs pycor >= 52 and abs pycor <= 61
[ set pcolor pink ]
if abs pxcor = 47 and abs pycor >= 51 and abs pycor <= 60
[ set pcolor pink ]
if abs pxcor = 48 and abs pycor >= 50 and abs pycor <= 60
[ set pcolor pink ]
if abs pxcor = 49 and abs pycor >= 49 and abs pycor <= 60
[ set pcolor pink ]
if abs pxcor = 50 and abs pycor >= 48 and abs pycor <= 59
[ set pcolor pink ]
if abs pxcor = 51 and abs pycor >= 47 and abs pycor <= 59
[ set pcolor pink ]
if abs pxcor = 52 and abs pycor >= 46 and abs pycor <= 58
[ set pcolor pink ]
if abs pxcor = 53 and abs pycor >= 45 and abs pycor <= 58
[ set pcolor pink ]
if abs pxcor = 54 and abs pycor >= 46 and abs pycor <= 57
[ set pcolor pink ]
if abs pxcor = 55 and abs pycor >= 47 and abs pycor <= 57
[ set pcolor pink ]
if abs pxcor = 56 and abs pycor >= 48 and abs pycor <= 56
[ set pcolor pink ]
if abs pxcor = 57 and abs pycor >= 49 and abs pycor <= 55
[ set pcolor pink ]
if abs pxcor = 58 and abs pycor >= 50 and abs pycor <= 55
[ set pcolor pink ]
if abs pxcor = 59 and abs pycor >= 51 and abs pycor <= 54
[ set pcolor pink ]
if abs pxcor = 60 and abs pycor >= 52 and abs pycor <= 53
[ set pcolor pink ]
; 509B, 503A, 514A, 520B
if abs pxcor = 55 and abs pycor >= 43 and abs pycor <= 44
[ set pcolor pink ]
if abs pxcor = 56 and abs pycor >= 42 and abs pycor <= 45
[ set pcolor pink ]
if abs pxcor = 57 and abs pycor >= 41 and abs pycor <= 46
[ set pcolor pink ]
if abs pxcor = 58 and abs pycor >= 40 and abs pycor <= 47
[ set pcolor pink ]
if abs pxcor = 59 and abs pycor >= 39 and abs pycor <= 48
[ set pcolor pink ]
if abs pxcor = 60 and abs pycor >= 38 and abs pycor <= 49
[ set pcolor pink ]
if abs pxcor = 61 and abs pycor >= 37 and abs pycor <= 50
[ set pcolor pink ]
if abs pxcor = 62 and abs pycor >= 36 and abs pycor <= 51
[ set pcolor pink ]
if abs pxcor = 63 and abs pycor >= 34 and abs pycor <= 50
[ set pcolor pink ]
if abs pxcor = 64 and abs pycor >= 34 and abs pycor <= 49
[ set pcolor pink ]
if abs pxcor = 65 and abs pycor >= 35 and abs pycor <= 48
[ set pcolor pink ]
if abs pxcor = 66 and abs pycor >= 35 and abs pycor <= 46
[ set pcolor pink ]
if abs pxcor = 67 and abs pycor >= 36 and abs pycor <= 45
[ set pcolor pink ]
if abs pxcor = 68 and abs pycor >= 36 and abs pycor <= 43
[ set pcolor pink ]
if abs pxcor = 69 and abs pycor >= 37 and abs pycor <= 41
[ set pcolor pink ]
if abs pxcor = 70 and abs pycor >= 37 and abs pycor <= 39
[ set pcolor pink ]
; 510, 502, 513, 521
if abs pxcor = 63 and abs pycor >= 24 and abs pycor <= 31
[ set pcolor pink ]
if abs pxcor = 64 and abs pycor >= 15 and abs pycor <= 32
[ set pcolor pink ]
if abs pxcor = 65 or abs pxcor = 66 and abs pycor >= 15 and abs pycor <= 33
[ set pcolor pink ]
if abs pxcor = 67 or abs pxcor = 68 and abs pycor >= 15 and abs pycor <= 34
[ set pcolor pink ]
if abs pxcor = 69 or abs pxcor = 70 and abs pycor >= 15 and abs pycor <= 35
[ set pcolor pink ]
if abs pxcor = 71 and abs pycor >= 15 and abs pycor <= 32
[ set pcolor pink ]
; paths (5th)
if abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23 and abs pycor >= 57 and abs pycor <= 61
[ set pcolor white set floor-number-patch 5 ]
if pxcor >= -31 and pxcor <= 31 and abs pycor = 56
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 31 and abs pxcor <= 38 and abs pycor = 55
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 38 and abs pxcor <= 44 and abs pycor = 54
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 44 and abs pxcor <= 45 and abs pycor = 53
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 45 and abs pxcor <= 46 and abs pycor = 52
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 46 and abs pxcor <= 47 and abs pycor = 51
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 47 and abs pxcor <= 48 and abs pycor = 50
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 48 and abs pxcor <= 49 and abs pycor = 49
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 49 and abs pxcor <= 50 and abs pycor = 48
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 50 and abs pxcor <= 51 and abs pycor = 47
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 51 and abs pxcor <= 52 and abs pycor = 46
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 52 and abs pxcor <= 53 and abs pycor = 45
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 53 and abs pxcor <= 54 and abs pycor = 44
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 54 and abs pxcor <= 55 and abs pycor = 43
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 55 and abs pxcor <= 56 and abs pycor = 42
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 56 and abs pxcor <= 57 and abs pycor = 41
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 57 and abs pxcor <= 58 and abs pycor = 40
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 58 and abs pxcor <= 59 and abs pycor = 39
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 59 and abs pxcor <= 60 and abs pycor = 38
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 60 and abs pxcor <= 61 and abs pycor = 37
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 61 and abs pxcor <= 62 and abs pycor = 36
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 62 and abs pycor >= 33 and abs pycor <= 35
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 63 and abs pycor >= 24 and abs pycor <= 33
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 64 and pycor >= -24 and pycor <= 24
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 42 and abs pycor >= 55 and abs pycor <= 56
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 43 and abs pycor >= 56 and abs pycor <= 59
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 44 and abs pycor >= 59 and abs pycor <= 61
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor = 45 and abs pycor >= 61 and abs pycor <= 62
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 54 and abs pxcor <= 55 and abs pycor = 45
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 55 and abs pxcor <= 56 and abs pycor = 46
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 56 and abs pxcor <= 57 and abs pycor = 47
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 57 and abs pxcor <= 58 and abs pycor = 48
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 58 and abs pxcor <= 59 and abs pycor = 49
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 59 and abs pxcor <= 60 and abs pycor = 50
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 60 and abs pxcor <= 61 and abs pycor = 51
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 61 and abs pxcor <= 62 and abs pycor = 52
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 64 and abs pxcor <= 65 and abs pycor = 33
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 65 and abs pxcor <= 67 and abs pycor = 34
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 67 and abs pxcor <= 69 and abs pycor = 35
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 69 and abs pxcor <= 70 and abs pycor = 36
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 65 and abs pxcor <= 71 and abs pycor = 14
[ set pcolor white set floor-number-patch 5 ]
if abs pxcor >= 65 and abs pxcor <= 71 and pycor = 0
[ set pcolor white set floor-number-patch 5 ]
; paths (4th)
if abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23 and abs pycor >= 44 and abs pycor <= 54
[ set pcolor white set floor-number-patch 4 ]
if pxcor >= -32 and pxcor <= 32 and abs pycor = 43
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 32 and abs pxcor <= 38 and abs pycor = 42
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 38 and abs pxcor <= 39 and abs pycor = 41
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 39 and abs pxcor <= 40 and abs pycor = 40
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 40 and abs pxcor <= 41 and abs pycor = 39
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 41 and abs pxcor <= 42 and abs pycor = 38
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 42 and abs pxcor <= 43 and abs pycor = 37
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 43 and abs pxcor <= 44 and abs pycor = 36
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 44 and abs pxcor <= 45 and abs pycor = 35
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 45 and abs pxcor <= 46 and abs pycor = 34
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 46 and abs pxcor <= 47 and abs pycor = 33
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 47 and abs pxcor <= 48 and abs pycor = 32
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 48 and abs pxcor <= 49 and abs pycor = 31
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 49 and abs pxcor <= 50 and abs pycor = 30
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 50 and abs pxcor <= 51 and abs pycor = 29
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 51 and abs pycor >= 25 and abs pycor <= 29
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 52 and pycor >= -25 and pycor <= 25
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 37 and abs pycor >= 42 and abs pycor <= 44
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 38 and abs pycor >= 44 and abs pycor <= 46
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 39 and abs pycor >= 46 and abs pycor <= 48
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 40 and abs pycor >= 48 and abs pycor <= 50
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor = 41 and abs pycor >= 50 and abs pycor <= 52
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 45 and abs pxcor <= 46 and abs pycor = 36
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 46 and abs pxcor <= 47 and abs pycor = 37
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 47 and abs pxcor <= 48 and abs pycor = 38
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 48 and abs pxcor <= 49 and abs pycor = 39
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 49 and abs pxcor <= 50 and abs pycor = 40
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 50 and abs pxcor <= 51 and abs pycor = 41
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 51 and abs pxcor <= 52 and abs pycor = 42
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 52 and abs pxcor <= 53 and abs pycor = 28
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 53 and abs pxcor <= 55 and abs pycor = 29
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 55 and abs pxcor <= 57 and abs pycor = 30
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 57 and abs pxcor <= 59 and abs pycor = 31
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 59 and abs pxcor <= 60 and abs pycor = 32
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 53 and abs pxcor <= 62 and abs pycor = 14
[ set pcolor white set floor-number-patch 4 ]
if abs pxcor >= 53 and abs pxcor <= 62 and pycor = 0
[ set pcolor white set floor-number-patch 4 ]
; paths (2nd)
if abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23 and abs pycor >= 24 and abs pycor <= 40
[ set pcolor white set floor-number-patch 2 ]
if pxcor >= -30 and pxcor <= 30 and abs pycor = 24
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 30 and abs pxcor <= 32 and abs pycor = 23
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 32 and abs pxcor <= 35 and abs pycor = 22
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 35 and abs pxcor <= 38 and abs pycor = 23
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 38 and abs pycor <= 23 and abs pycor >= 19
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 38 and abs pxcor <= 40 and abs pycor = 19
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 40 and abs pxcor <= 42 and abs pycor = 18
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 42 and abs pxcor <= 43 and abs pycor = 17
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 43 and pycor >= -16 and pycor <= 16
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 29 and abs pycor = 25
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 30 and abs pycor >= 25 and abs pycor <= 27
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 31 and abs pycor >= 27 and abs pycor <= 29
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 32 and abs pycor >= 29 and abs pycor <= 31
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 33 and abs pycor >= 31 and abs pycor <= 33
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 34 and abs pycor >= 33 and abs pycor <= 35
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 35 and abs pycor >= 35 and abs pycor <= 37
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor = 36 and abs pycor >= 37 and abs pycor <= 38
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 39 and abs pxcor <= 40 and abs pycor = 23
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 40 and abs pxcor <= 42 and abs pycor = 24
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 42 and abs pxcor <= 44 and abs pycor = 25
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 44 and abs pxcor <= 46 and abs pycor = 26
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 46 and abs pxcor <= 47 and abs pycor = 27
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 44 and abs pxcor <= 49 and abs pycor = 13
[ set pcolor white set floor-number-patch 2 ]
if abs pxcor >= 44 and abs pxcor <= 49 and pycor = 0
[ set pcolor white set floor-number-patch 2 ]
; exits (5th)
if (abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23) and abs pycor = 62
[ set pcolor green set floor-number-patch 5 ]
if abs pxcor = 45 and abs pycor >= 61 and abs pycor <= 62
[ set pcolor green set floor-number-patch 5 ]
if abs pxcor >= 61 and abs pxcor <= 62 and abs pycor = 52
[ set pcolor green set floor-number-patch 5 ]
if abs pxcor >= 69 and abs pxcor <= 70 and abs pycor = 36
[ set pcolor green set floor-number-patch 5 ]
if abs pxcor >= 70 and abs pxcor <= 71 and abs pycor = 14
[ set pcolor green set floor-number-patch 5 ]
if abs pxcor >= 70 and abs pxcor <= 71 and pycor = 0
[ set pcolor green set floor-number-patch 5 ]
; exits (4th)
if (abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23) and abs pycor = 54
[ set pcolor green set floor-number-patch 4 ]
if abs pxcor = 41 and abs pycor >= 51 and abs pycor <= 52
[ set pcolor green set floor-number-patch 4 ]
if abs pxcor >= 51 and abs pxcor <= 52 and abs pycor = 42
[ set pcolor green set floor-number-patch 4 ]
if abs pxcor >= 59 and abs pxcor <= 60 and abs pycor = 32
[ set pcolor green set floor-number-patch 4 ]
if abs pxcor >= 61 and abs pxcor <= 62 and abs pycor = 14
[ set pcolor green set floor-number-patch 4 ]
if abs pxcor >= 61 and abs pxcor <= 62 and pycor = 0
[ set pcolor green set floor-number-patch 4 ]
; exits (2nd)
if (abs pxcor = 7 or abs pxcor = 8 or abs pxcor = 22 or abs pxcor = 23) and abs pycor = 40
[ set pcolor green set floor-number-patch 2 ]
if abs pxcor = 36 and abs pycor >= 37 and abs pycor <= 38
[ set pcolor green set floor-number-patch 2 ]
if abs pxcor >= 46 and abs pxcor <= 47 and abs pycor = 27
[ set pcolor green set floor-number-patch 2 ]
if abs pxcor >= 48 and abs pxcor <= 49 and abs pycor = 13
[ set pcolor green set floor-number-patch 2 ]
if abs pxcor >= 48 and abs pxcor <= 49 and pycor = 0
[ set pcolor green set floor-number-patch 2 ]
; exits (1st)
if (abs pxcor = 36 and abs pycor = 20) or (abs pxcor = 35 and abs pycor = 20) or (abs pxcor = 36 and abs pycor = 19)
[ set pcolor green set floor-number-patch 1 ]
]
ask patches with [ pcolor = sky ] [ set floor-number-patch 1 ]
ask patches with [ pcolor = blue ] [ set floor-number-patch 2 ]
ask patches with [ pcolor = magenta ] [ set floor-number-patch 4 ]
ask patches with [ pcolor = pink ] [ set floor-number-patch 5 ]
ask patches with [ pcolor = black ] [
if pxcor <= 66 and pxcor >= -66 and pycor <= 55 and pycor >= -55
[ set pcolor gray ]
]
ask patches with [ pcolor = gray ] [
if abs pxcor <= 66 and abs pxcor >= 59 and abs pycor <= 55 and abs pycor >= 47
[ set pcolor black ]
]
if number_of_extinguishers >= 1 [
let exits-x-left-5 [ 6 -6 6 -6 21 -21 21 -21 44 -44 44 -44 60 -60 60 -60 70 -70 70 -70 71 -71 71 -71 71 -71]
let exits-y-left-5 [ 62 62 -62 -62 62 62 -62 -62 62 62 -62 -62 53 53 -53 -53 37 37 -37 -37 15 15 -15 -15 1 1 ]
let exits-x-right-5 [ 9 -9 9 -9 24 -24 24 -24 46 -46 46 -46 62 -62 62 -62 70 -70 70 -70 71 -71 71 -71 71 -71 ]
let exits-y-right-5 [ 62 62 -62 -62 62 62 -62 -62 61 61 -61 -61 51 51 -51 -51 35 35 -35 -35 13 13 -13 -13 -1 -1 ]
let exits-x-left-4 [ 6 -6 6 -6 21 -21 21 -21 40 -40 40 -40 51 -51 51 -51 60 -60 60 -60 62 -62 62 -62 62 -62 ]
let exits-y-left-4 [ 54 54 -54 -54 54 54 -54 -54 52 52 -52 -52 43 43 -43 -43 33 33 -33 -33 15 15 -15 -15 1 1 ]
let exits-x-right-4 [ 9 -9 9 -9 24 -24 24 -24 42 -42 42 -42 53 -53 53 -53 61 -61 61 -61 62 -62 62 -62 62 -62 ]
let exits-y-right-4 [ 54 54 -54 -54 54 54 -54 -54 52 52 -52 -52 41 41 -41 -41 31 31 -31 -31 13 13 -13 -13 -1 -1 ]
let exits-x-left-2 [ 6 -6 6 -6 21 -21 21 -21 35 -35 35 -35 46 -46 46 -46 49 -49 49 -49 49 -49 ]
let exits-y-left-2 [ 40 40 -40 -40 40 40 -40 -40 39 39 -39 -39 29 29 -29 -29 14 14 -14 -14 1 1 ]
let exits-x-right-2 [ 9 -9 9 -9 24 -24 24 -24 38 -38 38 -38 48 -48 48 -48 49 -49 49 -49 49 -49 ]
let exits-y-right-2 [ 40 40 -40 -40 40 40 -40 -40 37 37 -37 -37 26 26 -26 -26 12 12 -12 -12 -1 -1 ]
let exits-x-left-1 [ -34 34 -34 34 ]
let exits-y-left-1 [ 20 20 -20 -20 ]
let exits-x-right-1 [ -36 36 -36 36 ]
let exits-y-right-1 [ 18 18 -18 -18 ]
let i 0
while [i < length exits-x-left-5] [
ask patch item i exits-x-left-5 item i exits-y-left-5 [ set pcolor red - 0.5 set fire-extinguisher 1 ]
if number_of_extinguishers = 2 [ ask patch item i exits-x-right-5 item i exits-y-right-5 [ set pcolor red set fire-extinguisher 1 set floor-number-patch 5] ]
ask patch item i exits-x-left-4 item i exits-y-left-4 [ set pcolor red - 0.4 set fire-extinguisher 1 ]
if number_of_extinguishers = 2 [ ask patch item i exits-x-right-4 item i exits-y-right-4 [ set pcolor red set fire-extinguisher 1 set floor-number-patch 4 ] ]
if i < 22 [
ask patch item i exits-x-left-2 item i exits-y-left-2 [ set pcolor red - 0.2 set fire-extinguisher 1 ]
if number_of_extinguishers = 2 [ ask patch item i exits-x-right-2 item i exits-y-right-2 [ set pcolor red set fire-extinguisher 1 set floor-number-patch 2 ] ]
]
if i < 4 [
ask patch item i exits-x-left-1 item i exits-y-left-1 [ set pcolor red - 0.1 set fire-extinguisher 1 ]
if number_of_extinguishers = 2 [ ask patch item i exits-x-right-1 item i exits-y-right-1 [ set pcolor red set fire-extinguisher 1 set floor-number-patch 1 ] ]
]
set i i + 1
]
]
end
to setup-people
create-turtles fifth_floor [
set floor-number-turtle 5
move-to one-of patches with [floor-number-patch = 5 and pcolor = pink and not any? turtles-here]
]
create-turtles fourth_floor [
set floor-number-turtle 4
move-to one-of patches with [floor-number-patch = 4 and pcolor = magenta and not any? turtles-here]
]
create-turtles second_floor [
set floor-number-turtle 2
move-to one-of patches with [floor-number-patch = 2 and pcolor = blue and not any? turtles-here]
]
create-turtles first_floor [
set floor-number-turtle 1
move-to one-of patches with [floor-number-patch = 1 and pcolor = sky and not any? turtles-here]
]
ask turtles [
set speed 0.5 + random-float 1
set age 0
]
ask n-of ((fifth_floor + fourth_floor + second_floor + first_floor) / 100 * percentage_prepared) turtles [
set color red
set breed prepareds
]
ask n-of ((fifth_floor + fourth_floor + second_floor + first_floor) / 100 * percentage_listeners) turtles with [ breed != prepareds ][
set color yellow
set breed listeners
let curr-floor floor-number-turtle
set nearest-visible-exit patches in-radius 10 with [ pcolor = green and floor-number-patch = curr-floor ]
set is-alerted false
]
ask n-of ((fifth_floor + fourth_floor + second_floor + first_floor) / 100 * percentage_fighters) turtles with [ breed != prepareds and breed != listeners ][
set color violet
set breed fighters
set has-extinguisher false
set extinguisher-amount 50
]
create-helpers (26 * number_of_helpers) [
set color brown
set speed 0.5 + random-float 1
set floor-number-turtle 5
move-to one-of patches with [pcolor = green and floor-number-patch = 5 and count turtles-here = 0 and (count helpers in-radius 2 < number_of_helpers)]
set assigned-exit patch-here
]
create-helpers (26 * number_of_helpers) [
set color brown
set speed 0.5 + random-float 1
set floor-number-turtle 4
move-to one-of patches with [pcolor = green and floor-number-patch = 4 and count turtles-here = 0 and (count helpers in-radius 2 < number_of_helpers)]
set assigned-exit patch-here
]
create-helpers (22 * number_of_helpers) [
set color brown
set speed 0.5 + random-float 1
set floor-number-turtle 2
move-to one-of patches with [pcolor = green and floor-number-patch = 2 and count turtles-here = 0 and (count helpers in-radius 2 < number_of_helpers)]
set assigned-exit patch-here
]
create-helpers (4 * number_of_helpers) [
set color brown
set speed 0.5 + random-float 1
set floor-number-turtle 1
move-to one-of patches with [pcolor = green and floor-number-patch = 1 and count turtles-here = 0 and (count helpers in-radius 2 < number_of_helpers)]
set assigned-exit patch-here
]
end
to setup-fire
let curr-floor 0
ask patch fire_x fire_y [ set pcolor orange set curr-floor floor-number-patch ]
if curr-floor = 0 [ ask min-one-of patches with [ floor-number-patch != 0 ] [ distance myself ] [ set curr-floor floor-number-patch ] ]
if curr-floor = 1 or curr-floor = 2 [
ask turtles with [floor-number-patch = 1] [ set delay 5 ]
ask turtles with [floor-number-patch = 2] [ set delay 5 ]
ask turtles with [floor-number-patch = 4] [ set delay 10 ]
ask turtles with [floor-number-patch = 5] [ set delay 10 ]
]
if curr-floor = 4 or curr-floor = 5 [
ask turtles with [floor-number-patch = 1] [ set delay 10 ]
ask turtles with [floor-number-patch = 2] [ set delay 10 ]
ask turtles with [floor-number-patch = 4] [ set delay 5 ]
ask turtles with [floor-number-patch = 5] [ set delay 5 ]
]
end
to spread-fire
; spread fire after 2 ticks
if ticks mod 2 = 0 [
ask patches with [ pcolor = orange ] [
ask neighbors with [ pcolor != black ] [
; slower fire if changing floors
ifelse pcolor = gray
[ if random 100 < (rate_of_fire_spread / 10) [ set pcolor orange ] ]
[ if random 100 < rate_of_fire_spread [ set pcolor orange ] ]
]
]
]
set fire-count count patches with [ pcolor = orange ]
end
to move-prepared
ask prepareds [
if delay < ticks or distance min-one-of patches with [ pcolor = orange ] [ distance myself ] < 2 [
if [ pcolor ] of patch-here = orange [ set prepared-deaths prepared-deaths + 1 set ave-age-at-death ave-age-at-death + age die ]
let curr-floor floor-number-turtle
if fire-count > 0 [ find-nearest-exit ]
let empty-patch one-of patches in-radius speed with [ count turtles-here = 0 and floor-number-patch = curr-floor ]
ifelse front-is-wall-or-person? [
ifelse left-is-wall-or-person? [ right 45 + random 135 ][
ifelse right-is-wall-or-person? [ left 45 + random 135 ][ if empty-patch != nobody [move-to empty-patch] ]]][ face nearest-exit ]
forward speed
if distance nearest-exit < speed [
move-to nearest-exit
set prepared-evacuated prepared-evacuated + 1
set ave-age-at-evac ave-age-at-evac + age
die
]
]
]
end
to move-listeners
ask listeners [
if delay < ticks or distance min-one-of patches with [ pcolor = orange ] [ distance myself ] < 2 [
if [ pcolor ] of patch-here = orange [ set listener-deaths listener-deaths + 1 set ave-age-at-death ave-age-at-death + age die ]
let curr-floor floor-number-turtle
set nearest-visible-exit patches in-radius 6 with [ pcolor = green and floor-number-patch = curr-floor ]
let nearest-fire min-one-of patches with [ pcolor = orange ] [ distance myself ]
let nearest-helper min-one-of helpers with [ floor-number-turtle = curr-floor ] [ distance myself ]
let nearest-person min-one-of turtles with [ floor-number-turtle = curr-floor ] [ distance myself ]
let empty-patch one-of patches in-radius speed with [ count turtles-here = 0 and floor-number-patch = curr-floor ]
ifelse front-is-wall-or-person? [
ifelse left-is-wall-or-person? [ right 45 + random 135 ][
ifelse right-is-wall-or-person? [ left 45 + random 135 ][ if empty-patch != nobody [move-to empty-patch] ]]][
ifelse nearest-fire != nobody and distance nearest-fire <= 2 [ face nearest-fire right 180 ][
ifelse count nearest-visible-exit != 0 [ face min-one-of patches with [ pcolor = green and floor-number-patch = curr-floor ] [distance myself] ][
ifelse nearest-helper != nobody and is-alerted = true [ face nearest-helper ][
ifelse nearest-person != nobody and distance nearest-person <= 5 [ face nearest-person ][ face nearest-fire right 180 ]]]]]
if not front-is-wall-or-person? [forward speed]
if count nearest-visible-exit != 0 and distance min-one-of patches with [ pcolor = green and floor-number-patch = curr-floor ] [distance myself] < speed
[
move-to min-one-of patches with [ pcolor = green and floor-number-patch = curr-floor ] [distance myself]
set listener-evacuated listener-evacuated + 1
set ave-age-at-evac ave-age-at-evac + age
die
]
]
]
end
to move-helpers
ask helpers [
if delay < ticks or distance min-one-of patches with [ pcolor = orange ] [ distance myself ] < 2 [
if [ pcolor ] of patch-here = orange [ set helper-deaths helper-deaths + 1 set ave-age-at-death ave-age-at-death + age die ]
let curr-floor floor-number-turtle
let exit-distance distance assigned-exit
let nearest-fire min-one-of patches with [ pcolor = orange ] [ distance myself ]
let nearest-alert-listener min-one-of listeners with [ floor-number-turtle = curr-floor and count nearest-visible-exit = 0 and is-alerted = true ] [ distance myself ]
let lost-listeners listeners with [ floor-number-turtle = curr-floor and count nearest-visible-exit = 0 and is-alerted = false ]
ifelse nearest-fire != nobody and distance nearest-fire <= 2 [ face assigned-exit][
ifelse exit-distance > 30 [face assigned-exit][
ifelse nearest-alert-listener != nobody [ face assigned-exit ][
ifelse count lost-listeners != 0 [
face min-one-of listeners with [ floor-number-turtle = curr-floor and count nearest-visible-exit = 0 and is-alerted = false ] [distance myself]
ask lost-listeners in-radius 20 [
set is-alerted true
let nearest-lost-listener min-one-of listeners with [ floor-number-turtle = curr-floor and count nearest-visible-exit = 0 and is-alerted = false ] [ distance myself ]
if nearest-lost-listener != nobody [ face nearest-lost-listener ]
]]
[ face nearest-fire ]]]]
forward speed
if count listeners in-radius 50 with [floor-number-turtle = curr-floor] = 0
[
move-to assigned-exit
set helper-evacuated helper-evacuated + 1
set ave-age-at-evac ave-age-at-evac + age
die
]
]
]
end
to move-fighters
ask fighters [
if delay < ticks or distance min-one-of patches with [ pcolor = orange ] [ distance myself ] < 2 [
if [ pcolor ] of patch-here = orange [ set fighter-deaths fighter-deaths + 1 set ave-age-at-death ave-age-at-death + age die ]
let curr-floor floor-number-turtle
let nearest-extinguisher min-one-of patches with [ floor-number-patch = curr-floor and fire-extinguisher = 1 ] [ distance myself ]
let nearest-fire min-one-of patches with [ floor-number-patch = curr-floor and pcolor = orange ] [ distance myself ]
if fire-count > 0 [ find-nearest-exit ]
let empty-patch one-of patches in-radius speed with [ count turtles-here = 0 and floor-number-patch = curr-floor ]
ifelse front-is-wall-or-person? [
ifelse left-is-wall-or-person? [ right 45 + random 135 ][
ifelse right-is-wall-or-person? [ left 45 + random 135 ][ if empty-patch != nobody [move-to empty-patch] ]]][
; away from fire
ifelse nearest-fire != nobody and distance nearest-fire < 1 [ face nearest-fire right 180 ] [
; get fire extinguisher if available and has none
ifelse has-extinguisher = false and nearest-extinguisher != nobody [ face nearest-extinguisher ][
; evacuate if no more fire extiguishers
ifelse has-extinguisher = false and nearest-extinguisher = nobody [ face nearest-exit ][
; put out fires if possible, otherwise evacuate
ifelse has-extinguisher = true and extinguisher-amount > 0 and fire-count < 200 and fire-count != 0 and count patches with [ floor-number-patch = curr-floor and pcolor = orange ] != 0 and count patches in-radius 2 with [ pcolor = orange ] <= 8 [ face nearest-fire ] [ face nearest-exit ]]]]]
forward speed
; get fire extinguisher
if nearest-extinguisher != nobody and distance nearest-extinguisher < 2 [
set has-extinguisher true
ask nearest-extinguisher [ set fire-extinguisher 0
if curr-floor = 1 [set pcolor sky]
if curr-floor = 2 [set pcolor blue]
if curr-floor = 4 [set pcolor magenta]
if curr-floor = 5 [set pcolor pink]
]
]
; extinguish fire
if has-extinguisher = true and extinguisher-amount > 0 and (front-is-fire? or left-is-fire? or right-is-fire?) [