-
Notifications
You must be signed in to change notification settings - Fork 0
/
.SnailModel_NoPatchLimits.tmp.nlogo
2535 lines (2367 loc) · 91.1 KB
/
.SnailModel_NoPatchLimits.tmp.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 [snails snail] ;; set snail up as a breed of turtle
undirected-link-breed [friends friend] ;; sets up link for tracking non-unique contacts
undirected-link-breed [uniquefriends uniquefriend] ;; sets up link for tracking unique contacts
snails-own [
contact-count ;; snails keep track of contacts
unique-contact-count ;; snails keep track of unique contacts
last-meal ;; snails keep track of the last time they ate
patches-visited ;; a list of the unique patches a snail has visited
last-patch ;; the last patch the snail was on
patch-count ;; the number of times the snail has changed patches
patch-time ;; the average time a snail stays on a patch ;;{Does this need to exist? Just divide ticks by patch-count as needed?}
edge-time ;; time snails spend on the edge of the environment
edge-percent ;; percent time snails spend on the edge of the environment ;;{Does this need to exist? Just divide edge-time by ticks?}
sm ;; just a random number to compare against stochasticity value to determine if snail will move randomly
sick? ;; if true, the turtle is infectious
recovered? ; infected but then recovered, susceptible again?
sick-timer ; just a counter to keep track of exposed but not yet infectious or recovered timing
]
patches-own [
coverage ;; resource density on a patch, like algal percent cover
]
friends-own [
friendship-duration ;; the duration of the contact
]
globals [
snail-size ;; size of snails
aggregation-index ;; measures aggregation of the resources
contact-durations ;; list that holds all the durations of the contacts
avg-contact-duration ;; calculation of the average duration of a contact ;;{Does this need to exist? Just divide contact-durations by total #?}
;; variables on the interface not initialized in code
;feeding-rate ;; the feeding rate of the snails
;number-of-snails ; number of initial consumers
;movement-mode ; random movement or GUD based
; 99 = random, 1 = GUD-based movement
;stochasticity ; do consumers make mistakes in GUD?
;GUD ; giving up density as a percent, 0-100
;algae-distribution
; 99 = random, 0-6 equal 0/6, 1/6, 2/6, of old...
;initial-algae-coverage ; resource density as a percent, 0-100
;starting-infections ; number of initial infections among consumers
;infectiousness ; what proportion of contacts between infected and susceptible lead to infection? 0 to 1
;recover-time ; length of time infected consumer remains infectious
]
to setup
clear-links
clear-all
reset-ticks
;; initialize consumer traits
;set feeding-rate 5
set snail-size 5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Set up resource patches
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ask patches [set pcolor brown]
;; Are resource patches randomly distributed in the world? Then do this...
if (algae-distribution = 99) [
let random-tiles (list (random 144))
while [length random-tiles < 64] [
set random-tiles (lput (random 144) random-tiles)
set random-tiles (remove-duplicates random-tiles)
]
foreach random-tiles [ ?1 ->
let tile-xcor (?1 mod 12)
let tile-ycor (floor (?1 / 12))
ask patches with [pxcor = tile-xcor and pycor = tile-ycor] [ set pcolor lime ]
]
]
;; Are resource patches determined by aggregation index/experimental procedure? Then do this....
if (algae-distribution = 0) [
ask patches with [pxcor = 4 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 11] [ set pcolor lime ]
]
if (algae-distribution = 1) [
ask patches with [pxcor = 0 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 7] [ set pcolor lime ]
]
if (algae-distribution = 2) [
ask patches with [pxcor = 0 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 7] [ set pcolor lime ]
]
if (algae-distribution = 3) [
ask patches with [pxcor = 0 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 9] [ set pcolor lime ]
]
if (algae-distribution = 4) [
ask patches with [pxcor = 0 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 11] [ set pcolor lime ]
]
if (algae-distribution = 5) [
ask patches with [pxcor = 0 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 8 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 9 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 8] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 9] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 10] [ set pcolor lime ]
ask patches with [pxcor = 10 and pycor = 11] [ set pcolor lime ]
ask patches with [pxcor = 11 and pycor = 11] [ set pcolor lime ]
]
if (algae-distribution = 6) [
ask patches with [pxcor = 0 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 0 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 1 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 2 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 3 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 4 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 5 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 6 and pycor = 7] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 0] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 1] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 2] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 3] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 4] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 5] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 6] [ set pcolor lime ]
ask patches with [pxcor = 7 and pycor = 7] [ set pcolor lime ]
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this block calculates an aggregation index by asking algae tiles if there are algae tiles next to them
;; the logic is to ask each patch if they are algae covered, and if so, ask if there are algae patches on their four sizes.
;; because of the size of the world and the tiles, there are 24
;; opportunities for unique neighbors to be on different tiles, and the # out of 24 defines the aggregration index.
;; The code turns
;; patches from lime to green as it goes, so it only counts unique neighbor combinations. clever. Easiest to understand in the 6/6 aggregation
;; situation, where all the resources are clumped in the bottom left. first algae patch has one patch to the right and one below with algae.
;; the next two algae tiles across have the same. The last patch across the top
;; row has only one, the one on its bottom edge. 2 2 2 1. This pattern repeats for the next two rows. 2 2 2 1. Then the last row has only
;; new neighbor patches
;; on different tiles to its right... 1 1 1 0. 24 total. the maximum aggregation has 24/24. the minimum aggregation has 0/24. wow.
let algaefriends 0
ask patches [
if pcolor = lime [
let this-tile-pxcor pxcor
let this-tile-pycor pycor
set algaefriends algaefriends + (count neighbors4 with [ pcolor = lime and (pxcor != this-tile-pxcor or pycor != this-tile-pycor)])
set pcolor green
]
]
set aggregation-index algaefriends / 24
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set correct initial resource densities and color-code the patches
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set contact-durations [] ;; initialize list
set avg-contact-duration 0
ask patches [ ;; check if a patch has algae on it, and sets the biomass to what was previously calculated if so
if-else pcolor = green
[ set coverage initial-algae-coverage ]
[ set coverage 0 ]
if (coverage < GUD and coverage > 0) [ set pcolor 126 ] ;;set "alarm" color to indicate starting coverage is less than GUD
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; create consumers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set-default-shape snails "snail"
create-snails number-of-snails ;; settings for the snails
[
setxy random-xcor random-ycor ;; random placement
move-to patch-here
set color red
set size snail-size / 10
set contact-count 0
set unique-contact-count 0
set patches-visited (list (list [pxcor] of patch-here [pycor] of patch-here))
set last-patch patch-here
set patch-count 1
set patch-time (ticks / patch-count)
set edge-time 0
set edge-percent 0
set last-meal 0
set sick? false ;; if true, the turtle is infectious
;set exposed? false ;;infected but not infectious
set recovered? false
set sick-timer 0
set label who
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;start with some infection
let sickos (n-of starting-infections snails)
ask sickos [
set sick? true
set color black]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Order of procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
move-snails
count-all-snail-contacts
count-unique-snail-contacts
snails-eat
infect-snails
tick
calculate-patches-visited
calculate-patch-time
calculate-edge-time
; if ticks >= sim-duration [stop]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; infection procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to infect-snails
ask snails [
if not sick? AND not recovered? [
if any? turtles-here with [sick? = true]
[ if random 101 <= infectiousness ;if random number is less than or equal to infectionness unifected snail becomes infected
[set sick? true
set color black
set sick-timer 0]
]
]
]
ask snails with [sick? = true] [
set sick-timer sick-timer + 1
if sick-timer > recover-time
[set sick? false
set recovered? true
set color blue
;set sick-timer 0
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; consumer movement procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to move-snails ;; calls the appropriate movement mode for the snails based on the settings
ask snails [
ifelse (movement-mode = 99)
[ move-snails-random]
[set sm random 101 ;generates a random integer between 0 and 100
ifelse sm < stochasticity ;if random number is less than stoch snail moves random, else snail moves optiaml foraging
[ask self [ move-snails-random]] ; TRUE random number less than stochcasticty level
[ask self [ move-snails-optimal-foraging]]
]
]
end
;to move-snails-random ;; alternate procedure for moving the snails randomly
; move-to one-of neighbors
;end
;to move-snails-optimal-foraging ;; moves the snails simulating optimal foraging
; ifelse ([coverage] of patch-here > (GUD))
; [stop]
;[
;move-to patch-here ;; go to patch center
; let p (max-one-of neighbors [coverage]) ;; or neighbors4
; ifelse [coverage] of p >= [coverage] of patch-here
; [face p
; move-to p
; ]
; [move-to one-of neighbors]
; ]
;end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Rule of Two Movement
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to move-snails-random
fd 1 rt random 360
end
to move-snails-optimal-foraging ;; moves the snails simulating optimal foraging
ifelse ([coverage] of patch-here > (GUD))
[stop]
;[
;move-to patch-here ;; go to patch center
; let p (max-one-of neighbors [coverage]) ;; or neighbors4
; ifelse [coverage] of p >= [coverage] of patch-here
; [face p
; move-to p
; ]
[fd 1
rt random 360]
]
;]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; resource consumption
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to snails-eat ;; snails reduce the biomass of the patch they are on
ask patches [
set coverage coverage - (feeding-rate * (count snails-here))
if (coverage <= GUD and coverage > 0) [ set pcolor 126 ]
if (coverage <= 0) [
set coverage 0
set pcolor brown
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keeping track of contacts, unqiue contacts, and contact durations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NUMBER OF CONTACTS IS BEING DOUBLE COUNTED (A-B and B-A ARE COUNTED) NEED TO DVIDE THE OUTPUT BY 2
;; AVERAGE CONTACT DURATION OUTPUT IS CORRECT
; Each snail has list of duration and then average per snail
to count-all-snail-contacts ;; counts non-unique contacts between snails
ask snails [ ;; for each snail, count all snails it is in contact with
let firstsnail self ;; set a pointer to the snail that contacts are being counted for
let firstsnailnewfriends 0 ;; initialize counter for the contacts
ask other turtles-here [ ;; iterate through the first snail's neighbors
if (not friend-neighbor? firstsnail) [ ;; if there is not a link between them, create one and count the contact
create-friend-with firstsnail
set contact-count (contact-count + 1)
set firstsnailnewfriends (firstsnailnewfriends + 1)
]
]
set contact-count (contact-count + firstsnailnewfriends) ;; add the count of new links to the contact count
]
ask friends with [link-length >= 1] [ ;; break links between snails that have moved apart
;; friendship-duration is the current contact duration and contact duration is the list
set contact-durations (lput friendship-duration contact-durations) ;; input the contact information into the list
die ;; break the link
]
ask friends [ ;; ask the link if it is still there
set friendship-duration (friendship-duration + 1) ;; then add one to the duration
]
if-else ((length contact-durations + count friends) = 0) ; does this snail have any previous contact durations or current contacts
[ set avg-contact-duration 0 ] ;; if not set to zero
[ set avg-contact-duration ((sum contact-durations + sum [friendship-duration] of friends) / (length contact-durations + count friends)) ]
;; contact-durations is all previous contacts -- friendship durations is current contacts / previous + current contacts
;; because contact durations is only updated when current contact is over
;; only asking friends so contact durations is calculated off of the links -- therefore contact duration is correct
end
to count-unique-snail-contacts ;; sets new links to count unique contacts between snails
ask snails [ create-uniquefriends-with other turtles-here ]
ask snails [ set unique-contact-count (count uniquefriend-neighbors) ]
;; total possible unique contacts is n(n-1)/2, where n is number of snails
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keeping track of patches visited, time on a patch, resource levels, and time on edges of the world
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to calculate-patches-visited ;; maintain the list of patches the snail has visited
ask snails [
set patches-visited (lput (list [pxcor] of patch-here [pycor] of patch-here) patches-visited)
set patches-visited (remove-duplicates patches-visited)
]
end
to calculate-patch-time ;; calculates the average time the snails spend on each patch
ask snails [
if (([pxcor] of patch-here != [pxcor] of last-patch) or ([pycor] of patch-here != [pycor] of last-patch)) [
set patch-count (patch-count + 1)
]
set last-patch patch-here
set patch-time (ticks / patch-count)
]
end
to calculate-edge-time ;; calculates the time the snails spend on the edge of the environment
ask snails [
if (([pxcor] of patch-here = 0) or ([pxcor] of patch-here = 5) or ([pycor] of patch-here = 0) or ([pycor] of patch-here = 5)) [ set edge-time (edge-time + 1) ]
set edge-percent ((edge-time / ticks) * 100)
]
end
to-report resource-level
report sum [coverage] of patches / 6400
end
to-report report-edge-percent
report mean [edge-percent] of snails
end
to-report report-patch-time
report mean [patch-time] of snails
end
to-report Ss
report count turtles with [sick? = false AND recovered? = false]
end
to-report Is
report count turtles with [sick? = true]
end
to-report Rs
report count turtles with [recovered? = true]
end
to-report avg-contacts
report mean [contact-count] of snails
end
to-report total-contacts
report sum [contact-count] of snails
end
to-report avg-unique-contacts
report mean [unique-contact-count] of snails
end
to-report average-contact-duration
report mean [avg-contact-duration] of snails
end
to-report report-patches-visited
report mean [length patches-visited] of snails
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@#$#@#$#@
GRAPHICS-WINDOW
420
10
983
574
-1
-1
46.3
1
10
1
1
1
0
0
0
1
0
11
0
11
0
0
1
ticks
30.0
BUTTON
9
10
64
43
setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
85
10
140
43
go
go
T
1
T
OBSERVER
NIL
NIL