-
Notifications
You must be signed in to change notification settings - Fork 2
/
AxelrodSchelling.nlogo
1556 lines (1346 loc) · 47.2 KB
/
AxelrodSchelling.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
; Vito Vincenzo Covella
; email: [email protected]
; student ID number: 0000842689
extensions [ palette table nw ]
; interactions = number of moves or imitations occurred after the execution of the Axelrod-Schelling model
; layoutsMap = map from layout strings to anonymous functions used to build them
globals [ interactions layoutsMap editDistanceMap standardColors colorMapping emptyCounter codeCounter codeTable
plotInteractionCounter clusteringCoefficient density degree averagePathLength diameter ]
undirected-link-breed [ undirected-edges undirected-edge ]
turtles-own
[
emptySite? ;; if true, the site is not inhabited
code ;; site's cultural code
omega ;; site's average cultural overlap, USED FOR STATS PURPOSES ONLY. The main protocol model calls every time the appropriate function to get updated fresh values.
]
to setup
clear-all
resetRngSeed
; builds a map table from layoutChosen string to anonymous functions that build networks;
; this code is used to avoid nested ifelse
set layoutsMap table:make
table:put layoutsMap "spatially clustered network" [ -> setup-spatially-clustered-network ]
table:put layoutsMap "preferential attachment" [ -> setupPreferentialAttachment ]
table:put layoutsMap "Erdős–Rényi random network model" [ -> setupErdosRenyi ]
table:put layoutsMap "Watts-Strogatz small world" [ -> setupWattsStrogatz ]
table:put layoutsMap "Kleinberg model" [ -> setupKleinberg]
table:put layoutsMap "2D Lattice" [ -> setupLattice2D]
; builds a map from a chosen edit distance mechanism and the anonymous function used to compute it
set editDistanceMap table:make
table:put editDistanceMap "modified Hamming distance" [ [ a ] -> getModifiedHammingDistance a ]
table:put editDistanceMap "cosine similarity" [ [ a ] -> getCosineDistance a ]
set codeTable table:make
set-default-shape turtles "circle"
; this commands do not affect subsequent random events
with-local-randomness
[
; list of standard colors to use if we want to color different values for a single cultural trait
set standardColors sort sentence n-values 13 [i -> 13 + 10 * i] n-values 13 [i -> 15 + 10 * i]
set colorMapping n-of q_value standardColors
]
set interactions 0
;sets values used for stats purposes
set codeCounter 0
set clusteringCoefficient 0
set density 0
set degree 0
set averagePathLength 0
set diameter 0
; builds the chosen network layout
let setupNetwork table:get layoutsMap layoutChosen
run setupNetwork
initializeNetwork
with-local-randomness
[
set clusteringCoefficient mean [ nw:clustering-coefficient ] of turtles
calculateAveragePathLength
calculateDiameter
set degree mean [count my-links] of turtles
calculateDensity
registerCodeStats
]
set emptyCounter count turtles with [ emptySite? ]
output-print (word "Different cultural codes in the networks: " codeCounter)
redoColor
reset-ticks
end
to go
clear-output
with-local-randomness [ registerCodeStats ]
axelrodSchelling
;redoColor
with-local-randomness [ redoColor ]
; show interactions
with-local-randomness [ collectAverageOverlap ]
if interactions = 0
[
set plotInteractionCounter interactions
update-plots
stop
]
; we need another variable to save the old counter value, otherwise the plot will always show zero because interactions gets resetted at the end of the cycle
set plotInteractionCounter interactions
set interactions 0
tick
end
to resetRngSeed
ifelse fixedRandomSeed = true
[
; to create replicable results use specific seeds
; random-seed 95199254
random-seed customSeed
]
[
let seed new-seed
output-print word "The current seed is: " seed
random-seed seed
]
end
; Sets at least one node empty, other nodes are empty with a specific probability.
; Then non empty sites get a random cultural code.
to initializeNetwork
; at least one node must be empty
ask turtle 0
[
set emptySite? true
set omega 0
]
ask turtles with [ who != 0 ]
[
ifelse random-float 1 <= emptyProbability
[
set emptySite? true
]
[
set emptySite? false
; chose traits at random uniformly
set code n-values f_value [ i -> random q_value]
]
set omega 0
]
set emptyCounter count turtles with [ emptySite? ]
end
; this code comes from the Virus on a Network example in the Netlogo Library.
; As the name suggests, it builds spatially clustered networks
to setup-spatially-clustered-network
create-turtles numberOfNodes
[
; for visual reasons, we don't put any nodes *too* close to the edges
setxy (random-xcor * 0.95) (random-ycor * 0.95)
]
let num-links (averageNodeDegree * numberOfNodes) / 2
while [count links < num-links ]
[
ask one-of turtles
[
let choice (min-one-of (other turtles with [not link-neighbor? myself])
[distance myself])
if choice != nobody [ create-link-with choice ]
]
]
; make the network look a little prettier
repeat 10
[
layout-spring turtles links 0.3 (world-width / (sqrt numberOfNodes)) 1
]
end
; this is the main Axelrod-Schelling model
to axelrodSchelling
ask turtles with [ not emptySite? ]
[
;; if all neighbors are empty, directly move to another empty site
ifelse not any? link-neighbors with [ not emptySite? ]
[ move who ]
[
let peer one-of link-neighbors with [ not emptySite? ]
;; computes the kronecker's delta of each couple of items of the two corresponding item of the cultural code lists
;; then folds it by summing all the values
let culturalOverlap getCulturalOverlap self peer
;; with probability equal to cultural overlap copies one trait of the selected peer
ifelse random-float 1 <= culturalOverlap
[
; when the network is approaching the equilibrium state, most of the nodes will have cultural overlap equal to 1 and start imitating traits who are
; already equal. For this reason we must update the interactions only when the overlap is not at the maximum value, otherwise the simulation will
; never stop, even when no real changes happen in the population.
if culturalOverlap != 1 [set interactions interactions + 1]
let index random f_value
let trait item index [ code ] of peer
set code replace-item index code trait
]
[
;; if the averageCulturalOverlap is lower than the threshold, move to an empty site
let averageCulturalOverlap getAverageCulturalOverlap self
if averageCulturalOverlap < T_threshold [ move who ]
]
]
]
end
; computes and returns the cultural overlap between n1 and n2
to-report getCulturalOverlap [ n1 n2 ]
;; computes the kronecker's delta of each couple of items of the two corresponding item of the cultural code lists
;; then folds it by summing all the values
report (reduce + (map [ [a b] -> ifelse-value (a = b) [1] [0] ] [ code ] of n1 [ code ] of n2 )) / f_value
end
;; returns the average cultural overlap of n1 over its neighbors
to-report getAverageCulturalOverlap [ n1 ]
let average 0
ask link-neighbors with [ not emptySite? ]
[
set average average + getCulturalOverlap n1 self
]
report average / count link-neighbors with [ not emptySite? ]
end
; move the turtle identified by turtleID in another random empty site
to move [ turtleID ]
set interactions interactions + 1
let newSite one-of turtles with [ emptySite? ]
ask newSite [ set code [ code ] of turtle turtleID ]
;set [ code ] of newSite [ code ] of turtle turtleID
ask newSite [ set emptySite? false ]
ask turtle turtleID [set emptySite? true]
end
; computes the Euclidean norm of a list of values
to-report normalize [ n ]
report sqrt ( reduce + ( map [ [ a ] -> a * a ] n ) )
end
; computes the dot product between two lists of values
to-report dotProduct [ n1 n2 ]
report ( reduce + ( map [ [ a b] -> a * b ] n1 n1) )
end
; computes the cosine similarity
to-report getCosineSimilarity [ n1 n2 ]
report ( dotProduct n1 n2 ) / ( normalize n1 * normalize n2 + 0.000000001) ;; bias to prevent division by zero
end
to-report getCosineDistance [ codeList ]
report getCosineSimilarity codeList n-values f_value [0]
end
;; Reports a modified version of the Hamming distance between the cultural code provided as argument and the list made up of f_value zeros.
;; Instead of counting the number of differente values between the code given and a string of zeros, it sums the different values in the correspondinc positions
;; and the positions themselves. We need this last correction to distinguish between codes like [0 0 9 9] and [9 9 0 0].
to-report getModifiedHammingDistance [ codeList ]
let positions n-values f_value [ i -> i]
report (reduce + (map [ [a b c] -> ifelse-value (a != b) [a + c] [0] ] codeList n-values f_value [0] positions))
end
;; colors the sites following these rules
;; if the site is empty, set the color to white;
;; otherwise, if the user does not choos to color code on a single trait basis, choose an appropriate color in the reverse HSV gradient range from lime green to red.
;; The more the cultural code is similar to the code made up of zeros, the "greener" is the site.
;; First and last rgb value picked from https://www.colorhexa.com/32cd32-to-ff0000
;;
;; The distance used to measure similarity between cultural codes is the one chosen by the user in the interface
;;
;; If instead, the user decides to color code values on a single trait basis, use randomly assigned colors to this specific trait values
to redoColor
ifelse colorSingleTrait = false or q_value > length standardColors
[
ask turtles
[
ifelse (emptySite?)
[
set color white
]
[
let distanceChosen table:get editDistanceMap editDistance
let codeDistance ( runresult distanceChosen code )
;; minimum value possible is 0, maximum value is f_value times (q_value - 1) + (f_value - 1) (because of the positions)
if editDistance = "modified Hamming distance"
[ set color palette:scale-gradient [[50 205 50] [250 0 0]] codeDistance 0 (f_value * (q_value - 1) + (f_value - 1)) ]
if editDistance = "cosine similarity"
[ set color palette:scale-gradient [[50 205 50] [250 0 0]] codeDistance -1 1 ]
]
]
]
[
output-print (word "Trait chosen: " traitChosen ", out of " q_value " values")
output-print "These are the color values assigned (for detailes, see Tools->Color Watches)"
let i 0
foreach colorMapping
[
c -> output-print (word "Color for value " i ": " c)
set i i + 1
]
ask turtles
[
ifelse (emptySite?)
[ set color white ]
[
set color ( item (item traitChosen code) colorMapping )
]
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This next section is a slightly modified version of the Preferential Attachment netlogo example present in the library;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; used for creating a new node
to make-node [old-node]
create-turtles 1
[
if old-node != nobody
[ create-link-with old-node
;; position the new node near its partner
move-to old-node
fd 8
]
]
end
;; This code is the heart of the "preferential attachment" mechanism, and acts like
;; a lottery where each node gets a ticket for every connection it already has.
;; While the basic idea is the same as in the Lottery Example (in the Code Examples
;; section of the Models Library), things are made simpler here by the fact that we
;; can just use the links as if they were the "tickets": we first pick a random link,
;; and than we pick one of the two ends of that link.
to-report find-partner
report [one-of both-ends] of one-of links
end
to layout
;; the number 3 here is arbitrary; more repetitions slows down the
;; model, but too few gives poor layouts
repeat 3 [
;; the more turtles we have to fit into the same amount of space,
;; the smaller the inputs to layout-spring we'll need to use
let factor sqrt count turtles
;; numbers here are arbitrarily chosen for pleasing appearance
layout-spring turtles links (1 / factor) (7 / factor) (1 / factor)
display ;; for smooth animation
]
;; don't bump the edges of the world
let x-offset max [xcor] of turtles + min [xcor] of turtles
let y-offset max [ycor] of turtles + min [ycor] of turtles
;; big jumps look funny, so only adjust a little each time
set x-offset limit-magnitude x-offset 0.1
set y-offset limit-magnitude y-offset 0.1
ask turtles [ setxy (xcor - x-offset / 2) (ycor - y-offset / 2) ]
end
;; the UI and the code now use layout, this is for testing purposes when the previous procedure does not yield satisfactory results
to springLayout
let factor sqrt count turtles
if factor = 0 [ set factor 1 ]
layout-spring turtles links (1 / factor) (14 / factor) (1.5 / factor)
display
end
to-report limit-magnitude [number limit]
if number > limit [ report limit ]
if number < (- limit) [ report (- limit) ]
report number
end
to setupPreferentialAttachment
make-node nobody
make-node turtle 0
repeat numberOfNodes - 2
[
make-node find-partner
layout
]
repeat 20 [ layout ]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; generates a network following the Erdős–Rényi model
to setupErdosRenyi
nw:generate-random turtles undirected-edges numberOfNodes n-probability
layout-circle sort turtles max-pxcor * 0.9
end
; generates a network following the Watts-Strogatz model
to setupWattsStrogatz
nw:generate-watts-strogatz turtles undirected-edges numberOfNodes 2 n-probability
; William Thomas Tutte's layout
layout-circle sort turtles max-pxcor * 0.9
layout-tutte max-n-of (count turtles * 0.5) turtles [ count my-links ] links 24
end
;; generates a network following the Kleinberg model
to setupKleinberg
let dim 0
; to simplify things, we round up the square root of selected numberOfNodes (the algorithm works by first building a lattice rows * columns)
set dim round sqrt numberOfNodes
set numberOfNodes dim * dim
nw:generate-small-world turtles undirected-edges dim dim 2.0 false
; William Thomas Tutte's layout
layout-circle sort turtles max-pxcor * 0.9
layout-tutte max-n-of (count turtles * 0.5) turtles [ count my-links ] links 24
;repeat 10 [ layout-tutte (turtles with [link-neighbors = 1]) links 30 ]
end
;; generates a 2D lattice (useful for studying the behaviour of cities with grid-based layouts)
to setupLattice2D
let dim 0
; to simplify things, we round up the square root of selected numberOfNodes (the algorithm works by first building a lattice rows * columns)
set dim round sqrt numberOfNodes
set numberOfNodes dim * dim
; it is advised to use the redo layout button after this
nw:generate-lattice-2d turtles undirected-edges dim dim false
end
;; counts how many different cultural codes there are in the network. Moreover it stores this codes
;; in a table with their presence counter.
to registerCodeStats
set codeCounter 0
table:clear codeTable
let inhabitedSites turtles with [ not emptySite? ]
ask inhabitedSites
[
let currentCode code
let equalsSites turtles with [ code = currentCode ]
; set codeCounter codeCounter + count equalsSites
table:put codeTable currentCode count equalsSites
set inhabitedSites turtles with [ code != currentCode ]
]
set codeCounter table:length codeTable
end
;; computes and stores the average cultural overlap for each site
to collectAverageOverlap
ask turtles with [not emptySite?]
[
if any? link-neighbors with [ not emptySite? ]
[
let averageCulturalOverlap getAverageCulturalOverlap self
set omega averageCulturalOverlap
]
]
end
to colorOmegaLessThanOne
ask turtles with [ emptySite? ]
[
set color white
]
ask turtles with [ not emptySite? and omega = 1]
[
set color blue
]
ask turtles with [ not emptySite? and omega < 1]
[
set color yellow
]
end
;; calculates the edge density
to calculateDensity
set density 2 * (count links) / ( (count turtles) * (-1 + count turtles))
end
to calculateAveragePathLength
let meanPathLength nw:mean-path-length
ifelse meanPathlength = false
[set averagePathLength "infinity"]
[set averagePathLength meanPathLength]
end
to calculateDiameter
ifelse member? false reduce [ [a b] -> sentence a b] [[ nw:distance-to myself ] of other turtles ] of turtles
[set diameter "infinity"]
[set diameter max [ max [ nw:distance-to myself ] of other turtles ] of turtles]
end
;; color communities found using the Louvain algorithm
to colorCommunities
with-local-randomness
[
let communities nw:louvain-communities
let colors sublist (sentence standardColors white grey) 0 (length communities)
(foreach communities colors [ [community col] ->
ask community [ set color col ] ])
output-print word "Total number of different communities: " (length communities)
]
end
;; color connected components
to colorComponents
with-local-randomness
[
let components nw:weak-component-clusters
let colors sublist (sentence shuffle standardColors white grey) 0 (length components)
(foreach components colors [ [component col] ->
ask component [ set color col ] ])
]
end
;; assigns a color to each cultural code and then color the turtles with that specific code
;; useful at the end of the simulation, when cultural codes will not be more than the cardinality of standardColors
to mapColorPopulation
clear-output
output-print "These are the color values assigned for the following codes (for color names, see Tools->Color Watches)"
let currentCodes table:keys codeTable
ask turtles [set color white]
let colors sublist ( shuffle (fput (grey) standardColors) ) 0 (length currentCodes)
(foreach currentCodes colors [ [curCode col] ->
ask turtles with [code = curCode and not emptySite?] [ set color col ]
output-print (word curCode ": " col)])
end
@#$#@#$#@
GRAPHICS-WINDOW
385
10
974
600
-1
-1
8.94
1
10
1
1
1
0
0
0
1
-32
32
-32
32
0
0
1
ticks
30.0
SLIDER
12
371
184
404
f_value
f_value
1
100
3.0
1
1
NIL
HORIZONTAL
SLIDER
194
371
366
404
q_value
q_value
1
100
3.0
1
1
NIL
HORIZONTAL
SLIDER
196
419
368
452
T_threshold
T_threshold
0
1
0.51
0.01
1
NIL
HORIZONTAL
SLIDER
17
218
336
251
numberOfNodes
numberOfNodes
1
1000
400.0
1
1
NIL
HORIZONTAL
SLIDER
16
267
336
300
averageNodeDegree
averageNodeDegree
1
numberOfNodes - 1
12.0
1
1
NIL
HORIZONTAL
SLIDER
14
420
189
453
emptyProbability
emptyProbability
0
1
0.35
0.01
1
NIL
HORIZONTAL
BUTTON
35
73
116
106
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
151
73
241
106
go-once
go
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
BUTTON
259
73
322
106
NIL
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
CHOOSER
14
11
319
56
layoutChosen
layoutChosen
"spatially clustered network" "preferential attachment" "Erdős–Rényi random network model" "Watts-Strogatz small world" "Kleinberg model" "2D Lattice"
0
TEXTBOX
23
308
323
374
averageNodeDegree is taken in consideration only for the spatially clustered layout, not for other networks
12
0.0
1
CHOOSER
15
480
263
525
editDistance
editDistance
"modified Hamming distance" "cosine similarity"
0
BUTTON
32
115
137
148
redo color
with-local-randomness [ redoColor ]
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
SWITCH
172
117
341
150
colorSingleTrait
colorSingleTrait
1
1
-1000
SLIDER
17
577
235
610
traitChosen
traitChosen
0
q_value - 1
8.0
1
1
NIL
HORIZONTAL
TEXTBOX
20
533
286
569
traitChosen used only if colorSingelTrait is On. In this case, editDistance is ignored
12
0.0
1
OUTPUT
1038
19
1719
153
14
SWITCH
17
627
240
660
fixedRandomSeed
fixedRandomSeed
1
1
-1000
PLOT
994
166
1412
434
Network status
time
# counters
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"interactions" 1.0 0 -16777216 true "" "plot plotInteractionCounter"
"number of different codes" 1.0 0 -2674135 true "" "plot codeCounter"
PLOT
1450
166
1885
434
Cultural codes
codes
number of nodes
0.0
30.0
0.0
100.0
true
true
"\n" "clear-plot\nlet keys table:keys codeTable\nwith-local-randomness\n[\n let plotColors sentence n-values 13 [i -> 13 + 10 * i] n-values 13 [i -> 15 + 10 * i]\n \n (foreach keys [ k -> \n create-temporary-plot-pen (word k \"\")\n set-plot-pen-color one-of plotColors\n set-plot-pen-mode 1\n plotxy (position k keys + 1) table:get codeTable k ])\n]"
PENS
PLOT
992
465
1441
728
Cultural average overlaps
average overlap counter
counter
0.0
100.0
0.0
100.0
true
true
"" "clear-plot\nwith-local-randomness\n[\n let plotColors sentence n-values 13 [i -> 13 + 10 * i] n-values 13 [i -> 15 + 10 * i]\n let sites turtles with [ not emptySite? ]\n let i 1\n \n ask sites\n [\n let tOmega omega\n create-temporary-plot-pen (word tOmega \"\")\n set-plot-pen-color one-of plotColors\n set-plot-pen-mode 1\n plotxy i count sites with [ omega = tOmega ]\n set i i + 1.5\n set sites turtles with [ omega != tOmega ]\n ]\n]"
PENS
PLOT
1452
468
1885
730
Cultural average overlaps scatter plot
site ID
average overlap
0.0
100.0
0.0
1.5
true
false
"" "clear-plot\nwith-local-randomness\n[\n ask turtles with [not emptySite?]\n [\n create-temporary-plot-pen \"scatter\"\n set-plot-pen-color black\n set-plot-pen-mode 2\n plotxy who omega\n ]\n]"
PENS
PLOT
438
614
918
803
ratio of sites with average overlap < 1
time
(#overlap<1) / #sites
0.0
100.0
0.0
1.0
true
false
"" ""
PENS
"default" 1.0 0 -2674135 true "" "plot count turtles with [not emptySite? and omega < 1] / count turtles with [not emptySite?]"
BUTTON
9
682
244
715
color sites with average overlap < 1
colorOmegaLessThanOne
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
TEXTBOX
9
663
301
681
shows in yellow sites with average omega < 1
12
0.0
1
MONITOR
992
737
1152
782
Clustering coefficient
clusteringCoefficient
17
1
11
MONITOR
1172
737
1330
782
Density
density
17
1
11
MONITOR
1345
738
1518
783
Average degree
degree
17
1
11
MONITOR
1530
737
1695
782
Average path length
averagePathLength
17
1
11
MONITOR
1713
737
1871
782
Diameter
diameter
17
1
11
BUTTON
33
158
137
191
redo-layout
springLayout
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON