-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTeam Model 2.nlogo
2011 lines (1835 loc) · 63 KB
/
Team Model 2.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
extensions [array]
;; agents have a probablity to reproduce and a strategy
turtles-own [
cooperate-with-same? ;; probability agents will cooperate with the same color
cooperate-with-different? ;; probability agents will cooperate with a different color
raw-wealth
scaled-wealth
original
interactable
]
globals [
;; the remaining variables support the replication of published experiments
meet ;; how many interactions occurred this turn
meet-agg ;; how many interactions occurred through the run
last100meet ;; meet for the last 100 ticks
meetown ;; what number of individuals met someone of their own color this turn
meetown-agg ;; what number of individuals met someone of their own color throughout the run
last100meetown ;; meetown for the last 100 ticks
meetother ;; what number of individuals met someone of a different color this turn
meetother-agg ;; what number of individuals met someone of a different color throughout the run
last100meetother ;; meetother for the last 100 ticks
coopown ;; how many interactions this turn were cooperating with the same color
coopown-agg ;; how many interactions throughout the run were cooperating with the same color
last100coopown ;; coopown for the last 100 ticks
coopother ;; how many interactions this turn were cooperating with a different color
coopother-agg ;; how many interactions throughout the run were cooperating with a different color
defother ;; how many interactions this turn were defecting with a different color
defother-agg ;; how many interactions throughout the run were defecting with a different color
last100defother ;; defother for the last 100 ticks
last100cc ;; how many cooperate-cooperate genotypes have there been in the last 100 ticks
last100cd ;; how many cooperate-defect genotypes have there been in the last 100 ticks
last100dc ;; how many defect-cooperate genotypes have there been in the last 100 ticks
last100dd ;; how many defect-defect genotypes have there been in the last 100 ticks
last100consist-ethno ;; how many interactions consistent with ethnocentrism in the last 100 ticks
last100coop ;; how many interactions have been cooperation in the last 100 ticks
mine ;; the wealth that an agent has
yours ;; the wealth that another agent has while interacting
wealth-list ;; a list of turtles
percentile75 ;; the 75th percentile of wealth
percentile50 ;; the 50th percentile of wealth
percentile25 ;; the 25th percentile of wealth
northneighborcolor ;; color of the neighbor in north
eastneighborcolor ;; color of the neighbor in east
southneighborcolor ;; color of the neighbor in south
westneighborcolor ;; color of the neighbor in west
scale
in
turtles-total ;; total number of turtles
cluster ;; yet to be defined but put it here as reminder
]
to setup-empty
clear-all
initialize-variables
reset-ticks
end
;; creates a world with an agent on each patch
to setup-full
clear-all
initialize-variables
;; ask patches [ create-turtle ]
ask patches [ create-turtle-by-personality ]
form-teams
reset-ticks
end
to initialize-variables
;; initialize all the variables
set meetown 0
set meetown-agg 0
set meet 0
set meet-agg 0
set coopown 0
set coopown-agg 0
set defother 0
set defother-agg 0
set meetother 0
set meetother-agg 0
set coopother 0
set coopother-agg 0
set last100dd []
set last100cd []
set last100cc []
set last100dc []
set last100coopown []
set last100defother []
set last100consist-ethno []
set last100meetown []
set last100meetother []
set last100meet []
set last100coop []
set mine 0
set yours 0
set wealth-list []
set percentile75 0
set percentile50 0
set percentile25 0
set scale 1
set in 1
set cluster -1
set turtles-total 0
end
;; creates a new agent in the world
to create-turtle ;; patch procedure
sprout 1 [
set raw-wealth random-normal 50 25
if raw-wealth > 75 [ set color white]
if raw-wealth <= 75 and raw-wealth > 50 [ set color green ]
if raw-wealth <= 50 and raw-wealth > 25 [ set color yellow ]
if raw-wealth <= 25 [ set color red ]
set scaled-wealth raw-wealth
set original raw-wealth
;; determine the strategy for interacting with someone of the same color
set cooperate-with-same? (random-float 1.0 < chance-cooperate-with-same)
;; determine the strategy for interacting with someone of a different color
set cooperate-with-different? (random-float 1.0 < chance-cooperate-with-different)
;; change the shape of the agent on the basis of the strategy
set interactable 0
set turtles-total turtles-total + 1
update-shape
]
end
to create-turtle-by-personality ;; patch procedure
sprout 1 [
set raw-wealth random-normal 50 25
if raw-wealth > 75 [ set color white]
if raw-wealth <= 75 and raw-wealth > 50 [ set color green ]
if raw-wealth <= 50 and raw-wealth > 25 [ set color yellow ]
if raw-wealth <= 25 [ set color red ]
set scaled-wealth raw-wealth
set original raw-wealth
;; determine the strategy for interacting with someone of the same color
set cooperate-with-same? ( xcor mod 2 = 1)
set cooperate-with-different? (ycor mod 2 = 1)
;; change the shape of the agent on the basis of the strategy
set interactable 0
set turtles-total turtles-total + 1
update-shape
]
end
to-report random-color
report one-of [red white yellow green]
end
;; this is used to clear stats that change between each tick
to clear-stats
set meetown 0
set meet 0
set coopown 0
set defother 0
set meetother 0
set coopother 0
set cluster 0
;;set northneighborcolor 0
;;set eastneighborcolor 0
;;set southneighborcolor 0
;;set westneighborcolor 0
end
;; the main routine
to go
clear-stats ;; clear the turn based stats
;;immigrate ;; new agents immigrate into the world
ask turtles [update-state]
;;ask turtles [update-state-team]
ask turtles [resetraw]
;; reset the probability to reproduce
;;ask turtles [ set ptr initial-ptr ]
set wealth-list []
;; have all of the agents interact with other agents if they can
ask turtles [ interact ]
;;ask turtles [interact-team]
ask turtles [self-gain]
;; ask turtles [self-gain-team]
ask turtles [addwealth]
set wealth-list sort-by > wealth-list
if length wealth-list > 0 [set scale first wealth-list]
ask turtles[toscale]
;get-percentiles
;;ask turtles [colorandscale]
;; transact and then update your location
;;ask turtles with [ wealth > 0 ] [ transact ]
;; now they reproduce
;;ask turtles [ reproduce ]
;;death ;; kill some of the agents
update-stats ;; update the states for the aggregate and last 100 ticks
;;ask turtles [recolor]
ask turtles [clustering-team]
recolor-turtles
death
tick
if ticks mod check-grades-every = 0 [
ask turtles [
mutate
]
]
if ticks = 100 [stop]
end
to clustering-team ;; turtle procedure
let total-same 0.0
let myid xcor mod 2 + 2 * (ycor mod 2)
let decider [[0 -1] [1 0] [1 -1] ]
if myid = 0
[set decider [[0 -1] [1 0] [1 -1] ] ] ;; create list of locations
if myid = 1
[ set decider [[-1 -1] [-1 0] [0 -1] ]
]
if myid = 2
[ set decider [[0 1] [1 0] [1 1] ]
]
if myid = 3
[ set decider [[-1 0] [0 1] [-1 1] ]
]
while [length decider > 0 ] ;; must still have locations and be interactable
[
let location first decider
let x1 first location
let y1 last location
if length [interactable] of turtles-at x1 y1 > 0 ;; make sure turtle exists at location
[
let neighborcolor first [color] of turtles-at x1 y1
if (neighborcolor = color)
[
set total-same total-same + 1
]
]
set decider remove location decider ;;remove location used
]
set total-same total-same / 676
set cluster cluster + total-same
end
to form-teams
ask patches [
if pxcor mod 2 = 0 and (pycor + 1) mod 2 = 0 ;top left in box
[ask turtles-at 0 0 [create-link-with one-of turtles-at 1 0 create-link-with one-of turtles-at 0 -1 create-link-with one-of turtles-at 1 -1 ]]
if (pxcor + 1) mod 2 = 0 and (pycor + 1) mod 2 = 0 ;top right in box
[ask turtles-at 0 0 [create-link-with one-of turtles-at -1 0 create-link-with one-of turtles-at 0 -1 create-link-with one-of turtles-at -1 -1 ]]
if pxcor mod 2 = 0 and pycor mod 2 = 0 ;bottom left in box
[ask turtles-at 0 0 [create-link-with one-of turtles-at 1 0 create-link-with one-of turtles-at 0 1 create-link-with one-of turtles-at 1 1 ]]
if (pxcor + 1) mod 2 = 0 and pycor mod 2 = 0 ;bottom right in box
[ask turtles-at 0 0 [create-link-with one-of turtles-at -1 0 create-link-with one-of turtles-at 0 1 create-link-with one-of turtles-at -1 1 ]]
]
end
to self-gain
if interactable = 0 [set raw-wealth raw-wealth * self-gain-rate]
end
to update-state
if interactable > 0 [set interactable interactable - 1]
let leave floor random-exponential 1 ;; maybe future use slider 1 = mean of dirstibution
set interactable interactable + leave
end
to update-state-team
if interactable > 0 [set interactable 0]
;;let leave floor random-exponential 1 ;; maybe future use slider
;;set interactable interactable + leave
end
to resetraw
set raw-wealth scaled-wealth
end
;to get-percentiles
; set percentile50 median wealth-list
;let ending length wealth-list
;let middle ending * .5
;let lower sublist wealth-list middle ending
;let upper sublist wealth-list 0 middle
;set percentile75 median upper
;set percentile25 median lower
;end
to addwealth
set wealth-list fput raw-wealth wealth-list
end
to toscale
set scaled-wealth raw-wealth / scale * 100
end
;; random individuals enter the world on empty cells
;;to immigrate
;;let empty-patches patches with [not any? turtles-here]
;; we can't have more immigrants than there are empty patches
;;let how-many min list immigrants-per-day (count empty-patches)
;;ask n-of how-many empty-patches [ create-turtle ]
;;end
;to recolor
; if raw-wealth > percentile75 [set color white]
;if raw-wealth <= percentile75 and raw-wealth > percentile50 [set color green]
;if raw-wealth <= percentile50 and raw-wealth > percentile25 [set color yellow]
;if raw-wealth <= percentile25 [set color red]
;end
;; random individuals enter the world on empty cells
;;to immigrate
;;let empty-patches patches with [not any? turtles-here]
;; we can't have more immigrants than there are empty patches
;;let how-many min list immigrants-per-day (count empty-patches)
;;ask n-of how-many empty-patches [ create-turtle ]
;;end
to transact
;; give a dollar to another turtle
;;set wealth wealth + 1
;;ask one-of other turtles [ set wealth wealth + 1 ]
set mine raw-wealth
ask one-of turtles-on neighbors4 [set yours raw-wealth]
set raw-wealth raw-wealth + yours * exchange_rate - raw-wealth * cost-of-giving
ask one-of turtles-on neighbors4 [set raw-wealth raw-wealth + mine * exchange_rate - raw-wealth * cost-of-giving]
end
to interact ;; turtle procedure
let decider [[0 1] [1 0] [-1 0] [0 -1]] ;; create list of locations
set decider shuffle decider ;; shuffle list
while [interactable = 0 and length decider > 0 ] ;; must still have locations and be interactable
[
;;set check check + 1
let location first decider
let x1 first location
let y1 last location
if length [interactable] of turtles-at x1 y1 > 0 ;; make sure turtle exists at location
[
set in first [interactable] of turtles-at x1 y1
;; take first location
if in = 0 ;; make sure other turtle interatcable
[ ;;set check1 check1 + 1
let neighborcolor first [color] of turtles-at x1 y1
set meet meet + 1
set meet-agg meet-agg + 1
if (neighborcolor = color)
[
;;set check2 check2 + 1
set meetown meetown + 1
set meetown-agg meetown-agg + 1
if cooperate-with-same? and first [cooperate-with-same?] of turtles-at first location last location
[ set coopown coopown + 1
set coopown-agg coopown-agg + 1
set mine raw-wealth
set yours first [raw-wealth] of turtles-at x1 y1
set raw-wealth raw-wealth + yours * exchange_rate - mine * cost-of-giving
ask turtles-at x1 y1 ;; responder now gains
[
set raw-wealth raw-wealth + mine * exchange_rate - yours * cost-of-giving
set interactable 1
]
set interactable 1 ;; no more interactions
]
]
if neighborcolor != color
[
set meetother meetother + 1
set meetother-agg meetother-agg + 1
if cooperate-with-different? and first [cooperate-with-different?] of turtles-at x1 y1
[
set coopother coopother + 1
set coopother-agg coopother-agg + 1
set mine raw-wealth ;; wealth of turtle initiaiting
set yours first [raw-wealth] of turtles-at x1 y1 ; weath of responder
set raw-wealth raw-wealth + yours * exchange_rate - mine * cost-of-giving ;; new wealth of initiator
ask turtles-at x1 y1 ;; responder now gains
[
set raw-wealth raw-wealth + mine * exchange_rate - yours * cost-of-giving
set interactable 1
]
set interactable 1 ;; no more interactions
]
]
]
]
set decider remove location decider ;;remove location used
]
end
to self-gain-team
while [interactable < 4]
[ set raw-wealth raw-wealth * 1.2
set interactable interactable + 1
]
end
to interact-team ;; turtle procedure
let myid xcor mod 2 + 2 * (ycor mod 2)
let decider [[0 -1] [1 0] [1 -1] ]
if myid = 0
[set decider [[0 -1] [1 0] [1 -1] ] ] ;; create list of locations
if myid = 1
[ set decider [[-1 -1] [-1 0] [0 -1] ]
]
if myid = 2
[ set decider [[0 1] [1 0] [1 1] ]
]
if myid = 3
[ set decider [[-1 0] [0 1] [-1 1] ]
]
set decider shuffle decider ;; shuffle list
while [length decider > 0 ] ;; must still have locations and be interactable
[
;;set check check + 1
let location first decider
let x1 first location
let y1 last location
if length [interactable] of turtles-at x1 y1 > 0 ;; make sure turtle exists at location
[
set in first [interactable] of turtles-at x1 y1
;; take first location
if in < 4 ;; make sure other turtle interatcable
[ ;;set check1 check1 + 1
let neighborcolor first [color] of turtles-at x1 y1
set meet meet + 1
set meet-agg meet-agg + 1
if (neighborcolor = color)
[
;;set check2 check2 + 1
set meetown meetown + 1
set meetown-agg meetown-agg + 1
if cooperate-with-same? and first [cooperate-with-same?] of turtles-at first location last location
[ set coopown coopown + 1
set coopown-agg coopown-agg + 1
set mine raw-wealth
set yours first [raw-wealth] of turtles-at x1 y1
set raw-wealth raw-wealth + yours * exchange_rate - mine * cost-of-giving
;; ask turtles-at x1 y1 ;; responder now gains
;; [
;; set raw-wealth raw-wealth + mine * exchange_rate - yours * cost-of-giving
;; set interactable 1
;; ]
set interactable interactable + 1 ;; no more interactions
]
]
if neighborcolor != color
[
set meetother meetother + 1
set meetother-agg meetother-agg + 1
if cooperate-with-different? and first [cooperate-with-different?] of turtles-at x1 y1
[
set coopother coopother + 1
set coopother-agg coopother-agg + 1
set mine raw-wealth ;; wealth of turtle initiaiting
set yours first [raw-wealth] of turtles-at x1 y1 ; weath of responder
set raw-wealth raw-wealth + yours * exchange_rate - mine * cost-of-giving ;; new wealth of initiator
;;ask turtles-at x1 y1 ;; responder now gains
;;[
;; set raw-wealth raw-wealth + mine * exchange_rate - yours * cost-of-giving
;;set interactable 1
;;]
set interactable interactable + 1 ;; no more interactions
]
]
]
]
set decider remove location decider ;;remove location used
]
end
;; use PTR to determine if the agent gets to reproduce
;;to reproduce ;; turtle procedure
;; if a random variable is less than the PTR the agent can reproduce
;; if random-float 1.0 < ptr [
;; find an empty location to reproduce into
;; let destination one-of neighbors4 with [not any? turtles-here]
;;if destination != nobody [
;; if the location exists hatch a copy of the current turtle in the new location
;; but mutate the child
;;hatch 1 [
;;move-to destination
;;mutate
;; ]
;; ]
;; ]
;;end
;; modify the children of agents according to the mutation rate
;;to mutate ;; turtle procedure
;; mutate the color
;;if random-float 1.0 < mutation-rate [
;;let old-color color
;;while [color = old-color]
;;[ set color random-color ]
;;]
;; mutate the strategy flags;
;; use NOT to toggle the flag
;;if random-float 1.0 < mutation-rate [
;;set cooperate-with-same? not cooperate-with-same?
;;]
;;if random-float 1.0 < mutation-rate [
;;set cooperate-with-different? not cooperate-with-different?
;;]
;; make sure the shape of the agent reflects its strategy
;;update-shape
;;end
to mutate ;; turtle procedure
if color != white and random-float 1.0 < mutation-rate [
set cooperate-with-same? not cooperate-with-same?
]
if color != white and random-float 1.0 < mutation-rate [
set cooperate-with-different? not cooperate-with-different?
]
;;make sure the shape of the agent reflects its strategy
update-shape
end
to death
;; check to see if a random variable is less than the death rate for each agent
ask turtles [
if random-float 1.0 < death-rate
[
die
set turtles-total turtles-total - 1
]
]
end
;; make sure the shape matches the strategy
to update-shape
;; if the agent cooperates with same they are a circle
ifelse cooperate-with-same? [
ifelse cooperate-with-different?
[ set shape "circle" ] ;; filled in circle (altruist)
[ set shape "circle 2" ] ;; empty circle (ethnocentric)
]
;; if the agent doesn't cooperate with same they are a square
[
ifelse cooperate-with-different?
[ set shape "square" ] ;; filled in square (cosmopolitan)
[ set shape "square 2" ] ;; empty square (egoist)
]
end
to recolor-turtles
set wealth-list sort-on[raw-wealth]turtles
set percentile75 [raw-wealth] of item (0.75 * length(wealth-list)) wealth-list ;; fixed hardcode
set percentile50 [raw-wealth] of item (0.50 * length(wealth-list)) wealth-list
set percentile25 [raw-wealth] of item (0.25 * length(wealth-list)) wealth-list
ask turtles
[ifelse (raw-wealth >= percentile75)
[set color white]
[ifelse (raw-wealth < percentile75 and raw-wealth >= percentile50)
[set color green]
[ifelse (raw-wealth < percentile50 and raw-wealth >= percentile25)
[set color yellow]
[set color red] ] ] ]
end
;to scale100 ;; scaling everything to base 100
; set wealth-list sort-on[raw-wealth] turtles
; let counter 0
; let scale [raw-wealth] of item 0 turtles-list / 100
; while [counter < length turtles-list]
;[
;;set [scaled-wealth] of item counter mylist [wealth] of item counter mylist * scale
;; change list to array to make mutable
; set counter counter + 1
;]
;end
;; this routine calculates a moving average of some stats over the last 100 ticks
to update-stats
;;set last100dd shorten lput (count turtles with [shape = "square 2"]) last100dd
;;set last100cc shorten lput (count turtles with [shape = "circle"]) last100cc
;;set last100cd shorten lput (count turtles with [shape = "circle 2"]) last100cd
;;set last100dc shorten lput (count turtles with [shape = "square"]) last100dc
set last100coopown shorten lput coopown last100coopown
set last100defother shorten lput defother last100defother
set last100meetown shorten lput meetown last100meetown
set last100coop shorten lput (coopown + coopother) last100coop
set last100meet shorten lput meet last100meet
set last100meetother shorten lput meetother last100meetother
end
;; this is used to keep all of the last100 lists the right length
to-report shorten [the-list]
ifelse length the-list > 100
[ report butfirst the-list ]
[ report the-list ]
end
;; these are used in the BehaviorSpace experiments
to-report meetown-percent
report meetown / max list 1 meet
end
to-report meetown-agg-percent
report meetown-agg / max list 1 meet-agg
end
to-report coopown-percent
report coopown / max list 1 meetown
end
to-report coopown-agg-percent
report coopown-agg / max list 1 meetown-agg
end
to-report defother-percent
report defother / max list 1 meetother
end
to-report defother-agg-percent
report defother-agg / max list 1 meetother-agg
end
to-report consist-ethno-percent
report (defother + coopown) / (max list 1 meet )
end
to-report consist-ethno-agg-percent
report (defother-agg + coopown-agg) / (max list 1 meet-agg )
end
to-report coop-percent
report (coopown + coopother) / (max list 1 meet )
end
to-report coop-agg-percent
report (coopown-agg + coopother-agg) / (max list 1 meet-agg)
end
to-report cc-count
report sum last100cc / max list 1 length last100cc
end
to-report cd-count
report sum last100cd / max list 1 length last100cd
end
to-report dc-count
report sum last100dc / max list 1 length last100dc
end
to-report dd-count
report sum last100dd / max list 1 length last100dd
end
to-report cc-percent
report cc-count / (max list 1 (cc-count + cd-count + dc-count + dd-count))
end
to-report cd-percent
report cd-count / (max list 1 (cc-count + cd-count + dc-count + dd-count))
end
to-report dc-percent
report dc-count / (max list 1 (cc-count + cd-count + dc-count + dd-count))
end
to-report dd-percent
report dd-count / (max list 1 (cc-count + cd-count + dc-count + dd-count))
end
to-report last100coopown-percent
report sum last100coopown / max list 1 sum last100meetown
end
to-report last100defother-percent
report sum last100defother / max list 1 sum last100meetother
end
to-report last100consist-ethno-percent
report (sum last100defother + sum last100coopown) / max list 1 sum last100meet
end
to-report last100meetown-percent
report sum last100meetown / max list 1 sum last100meet
end
to-report last100coop-percent
report sum last100coop / max list 1 sum last100meet
end
to-report northneighborcolor1
report northneighborcolor
end
to-report eastneighborcolor1
report eastneighborcolor
end
to-report southneighborcolor1
report southneighborcolor
end
to-report westneighborcolor1
report westneighborcolor
end
to-report turtle-id
report [who] of turtle-set wealth-list
end
to-report raw-wealth1
report [raw-wealth] of turtle-set wealth-list
end
; Copyright 2003 Uri Wilensky.
; See Info tab for full copyright and license.
@#$#@#$#@
GRAPHICS-WINDOW
323
10
582
270
-1
-1
9.67
1
10
1
1
1
0
1
1
1
0
25
0
25
0
0
1
ticks
30.0
SLIDER
14
204
180
237
mutation-rate
mutation-rate
0.0
1.0
0.0
0.0010
1
NIL
HORIZONTAL
SLIDER
13
246
179
279
death-rate
death-rate
0.0
0.1
0.0
0.001
1
NIL
HORIZONTAL
SLIDER
17
123
163
156
cost-of-giving
cost-of-giving
0.0
1.0
0.05
0.01
1
NIL
HORIZONTAL
BUTTON
20
29
128
62
setup empty
setup-empty
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
222
29
295
62
NIL
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
PLOT
592
230
893
436
Altruist vs. Rank
time
count
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"100%-75%" 1.0 0 -16777216 true "" "plotxy ticks count turtles with [shape = \"circle\" and color = white] "
"75%-50%" 1.0 0 -8732573 true "" "plotxy ticks count turtles with [shape = \"circle\" and color = green]"
"50%-25%" 1.0 0 -987046 true "" "plotxy ticks count turtles with [shape = \"circle\" and color = yellow]"
"25%-0%" 1.0 0 -2139308 true "" "plotxy ticks count turtles with [shape = \"circle\" and color = red]"
BUTTON
130
29
219
62
setup full
setup-full
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
12
288
325
321
chance-cooperate-with-same
chance-cooperate-with-same
0.0
1.0
0.5
0.01
1
NIL
HORIZONTAL
SLIDER
11
332
324
365
chance-cooperate-with-different
chance-cooperate-with-different
0.0
1.0
0.5
0.01
1
NIL
HORIZONTAL
SLIDER
15
163
187
196
exchange_rate
exchange_rate
0.01
1
0.2
0.01
1
NIL
HORIZONTAL
PLOT
891
231
1178
435
Ethnocentric vs. Rank
time
count
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"100%-75%" 1.0 0 -16777216 true "" "plotxy ticks count turtles with [shape = \"circle 2\" and color = white] "
"75%-50%" 1.0 0 -8732573 true "" "plotxy ticks count turtles with [shape = \"circle 2\" and color = green] "
"50%-25%" 1.0 0 -987046 true "" "plotxy ticks count turtles with [shape = \"circle 2\" and color = yellow] "
"25%-0%" 1.0 0 -2139308 true "" "plotxy ticks count turtles with [shape = \"circle 2\" and color = red] "
PLOT
891
27
1178
232
Egoist vs. Rank
time
count
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"100%-75%" 1.0 0 -16777216 true "" "plotxy ticks count turtles with [shape = \"square 2\" and color = white] "
"75%-50%" 1.0 0 -8732573 true "" "plotxy ticks count turtles with [shape = \"square 2\" and color = green] "
"50%-25%" 1.0 0 -987046 true "" "plotxy ticks count turtles with [shape = \"square 2\" and color = yellow] "
"25%-0%" 1.0 0 -2139308 true "" "plotxy ticks count turtles with [shape = \"square 2\" and color = red] "
PLOT
592
28
893
232
Cosmopolitan vs. Rank
time
count
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"100%-75%" 1.0 0 -16777216 true "" "plotxy ticks count turtles with [shape = \"square\" and color = white]"
"75%-50%" 1.0 0 -8732573 true "" "plotxy ticks count turtles with [shape = \"square\" and color = green] "
"50%-25%" 1.0 0 -987046 true "" "plotxy ticks count turtles with [shape = \"square\" and color = yellow] "
"25%-0%" 1.0 0 -2139308 true "" "plotxy ticks count turtles with [shape = \"square\" and color = red] "
SLIDER
16
89
245
122
check-grades-every
check-grades-every
1
100
100.0
1
1
days
HORIZONTAL
TEXTBOX
359
281
581
533
\n\"Ethnocentric\"-cooperates with same colored agents, but does not cooperate with different colored agents (empty circle)\n\"Altruist\"-cooperates with all agents (filled circle)\n\"Cosmopolitan\"-cooperates with different color agents, but not with the same color agents (filled square)\n\"Egoist\"-cooperates with no one (empty square)\n\nWhite is the 100th-75th percentile\nGreen is the 75th-50th percentile\nYellow is the 50th-25th percentile\nRed is the 25th-0th percentile
11
0.0
0
SLIDER
15
374
187