-
Notifications
You must be signed in to change notification settings - Fork 1
/
p2pvalueModel.nlogo
6964 lines (6432 loc) · 238 KB
/
p2pvalueModel.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
; Developed by Dr Peter Barbrook-Johnson 2015 as part of the p2pvalue EU project
; Comments welcome - email: [email protected]
; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions
; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions
; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions; Extensions
extensions [profiler]
;setup ;; set up the model
;profiler:start ;; start profiling
;repeat 20 [ go ] ;; run something you want to measure
;profiler:stop ;; stop profiling
;print profiler:report ;; view the results
;profiler:reset ;; clear the data
; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters
; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters
; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters; Global Parameters
globals [
; platform-features ; chooser for current platform features turned on/off
; proportion-using-platform ; proportion of 1/9/90 using the software platform
; initial-number-#1s ; initial numbers of these agents
; initial-number-#9s
; initial-number-#90s
; initial-projects
; initial-tasks
initial-products
; num-interest-categories ; number of discrete 'interest' categories
; prop-of-projects-reward-subjective ; proportion of tasks that have their reward decided subjectively -
; ie., variation / not as predictable
; prop-consumed-each-time ; proportion of a product that is consumed by each #90 on each timestep
; currently just used to measure level of consumption by 90
; not depletion of product - ie., assume non-rivalrous
; reward-mechanism ; chooser specifying which reward mechanism is currently being used
; chance-of-finding-new-task ; chance per tick working on a task idenitfies a new task
#1s-left ; count of these agents who have left communuity
#9s-left
#90s-left
#90s-left-no-product ; count of why 90s left (currently only 1 reason why they leave)
new-#9s-total ; count of new #9 entered the community
new-#90s-total ; count of new #90s entered the community
new-#90s-chance
new-#1-count ; count of new #1s
products-consumed ; count products consumed
tasks-completed ; count tasks completed
new-tasks-count ; count of new tasks created
new-products-count ; count of new products created
#9-to-#1-count ; count of #9 turned into #1
#1-to-#9-count ; count of #1s turned to #9
#90-to-#9-count
#90-used-featured-needs ; count of 90s using featured needs
new-#9-attracted-by-#90s ; recored why a 9 entered
num-skills ; number of skill types for projects or contributors
#9-left-no-interest ; recording why #9 leave comm
#9-left-drop-cons
#9-left-burnout
#1-left-burnout ; recording why #1 left
time-with-no-#1s ; recording ticks with no agents
time-with-no-#9
time-with-no-#90s
time-with-no-products
time-with-no-tasks
projects-died ; count of projects 'died'
projects-finished ; count of projects finished
loneTasksFinished
count-new-projects ; count new projects appearing
product-had-no-consumer-so-left ; count of reasons why product 'died'
products-out-competed ; record of times, in a one product commmunity,
; that a choice has been made between two
contributions-made-by-1s ; count of indiviudal contributions made
time-contributed-by-1s ; count of hours contributed
contributions-made-by-9s ; count of indiviudal contributions made
time-contributed-by-9s ; count of hours contributed
#1-dropped-a-task ; record dropping of tasks and projects
#9-dropped-a-task
#1-dropped-a-project
#9-dropped-a-project
; chance-90-find-a-task ; chance a 90 sees a task that makes them decide to become a 9
; - higher with platform
community-prod-activity-ls ; list of the history of community production activity
community-con-activity-ls ; list of the history of community consumption activity
]
; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types
; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types
; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types; Agent types
breed [#1s #1]
breed [#9s #9]
breed [#90s #90]
breed [projects project]
breed [t4sks t4sk]
breed [loneTasks loneTask]
breed [products product]
undirected-link-breed [tasklinks tasklink]
undirected-link-breed [lonetasklinks lonetasklink]
undirected-link-breed [friendlinks friendlink]
undirected-link-breed [consumerlinks consumerlink]
undirected-link-breed [projectproductlinks projectproductlink]
; Agent parameters by type; Agent parameters by type; Agent parameters by type; Agent parameters by type
; Agent parameters by type; Agent parameters by type; Agent parameters by type; Agent parameters by type
; Agent parameters by type; Agent parameters by type; Agent parameters by type; Agent parameters by type
#1s-own [
my-projects-1s ; list (actual list) of projects 1 attached to
my-tasks-1s ; list (agentset) of tasks currently contributing to
my-lone-tasks-1s ; list (agentset) of lonetasks currently contributing to
my-projects ;
my-tasks ; these 4 used when changing breeds
my-lone-tasks
my-friends ;
my-time ; static time availability for community - random 40
time ; current spare time available (not being used on tasks already)
skill ; skill types - 3 values from a possible 10
interest ; interest score - random num-interest-categories
using-platform? ; yes/no - is the #1 using the platform?
points ; count quant reward/point received by agent
thanks ; have they received thanks and who from
time-in-community ; count ticks/weeks spent in community
contribution-history-1s ; list with contribution in previous N ticks
contribution-history-9s ; used when changing breed
my-total-contribution-1s ; count of previous contributions
my-total-contribution-9s ; used when changing breed
feel-loved ; variable based on thanks and points used in decisions
]
#9s-own [
my-projects ; list (actual list) of projects 9 attached to
my-tasks ; list (agentset) of tasks currently contributing to
my-lone-tasks ; list (agentset) of lone tasks currently contributing to
my-friends ; list (agentset) of other 9s currently friends with
my-projects-1s ;
my-tasks-1s ; used when changing breeds
my-lone-tasks-1s
my-time ; static time availability for community - random 40
time ; current spare time available (not being used on tasks already)
skill ; skill types - 3 values from a possible 10
interest ; interest score - random num-interest-categories
using-platform? ; yes/no - is the #9 using the platform?
points ; count reward received by agent
thanks ; have they received thanks and who from
time-in-community ; count ticks/weeks spent in community
time-with-no-links ; count ticks #9 has had no tasks
contribution-history-9s ; list with contribution in previous N ticks
contribution-history-1s ; used when changing breeds
my-total-contribution-9s ; count of previous contributions
my-total-contribution-1s ; used when changing breed
feel-loved
i-used-featured? ; did the 9 ever find a featured need
]
#90s-own [
interest ; interest score - random num-interest-categories
consumption ; count level of volume consumed from products
time-in-community ; count ticks/weeks spent in community
time-without-products ; count ticks with no product to consume
using-platform? ; yes/no - is the #90 using the platform?
skill ; skill types - 3 values from a possible 10
]
projects-own [
inter3st ; interest score - random num-interest-categories
num-tasks ; number of tasks currently in project
my-tasks-projects ; the tasks of this project
production-activity ; score - count of current contributors to project's tasks weighted by distance
production-history ; 10 tick history of production-activity
age ; time task has been in community
my-product ; product that the project links to, can be 'nobody'
likes ; used in position in list
likes-history ; 10 tick history of likes
reward-type ; obj or subj - how reward to each contributor is decided
reward-level ; amount of reward random 100
current-contributors ; agentset of current contributors to tasks of this project
is-on-platform? ; is the project on the platform?
is-private? ; is the project private?
total-bounty ; the combined bounty of tasks within this project
]
t4sks-own [
my-project ; project task is within
typ3 ; skil type required by task - one of ten
inter3st ; interest score - random num-interest-categories
time-required ; time required to complete tasks random normal 50 10
modularity ; contribution required by task per tick
age ; time task has been in community
featured? ; is the task currently being featured?
bounty ; the bounty given to a task by its project's contributors
]
loneTasks-own [
typ3 ; skil type required by task - one of ten
inter3st ; interest score - random num-interest-categories
time-required ; time required to complete tasks random normal 50 10
modularity ; contribution required by task per tick
age
my-product-L ; product task is associated with
]
products-own [
inter3st ; interest score - random num-interest-categories
volume ; volume of consumable value product has
consumption-activity ; count of number of current consumers of this product
age ; time product has been in community
mon-project ; project product is associated with
consumption-history ; list of recent consumerlinks per tick
]
tasklinks-own [ ageTL ] ; all links have an age parameter
friendlinks-own [ ageFL
times-worked-together ]
consumerlinks-own [ ageCL ]
projectproductlinks-own [ agePL ]
; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup
; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup
; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup ; Setup
to setup
clear-all
;; colour lines to mark projects and products spaces
ask patches with [pxcor = 17 OR pxcor = -5 OR pxcor = -14 OR pxcor = -4] [set pcolor white]
;; set some globals to zero
setup-globals
;; create agents
if number-of-products = "one" [ set initial-products 1 ]
if number-of-products = "a few" [ set initial-products random 5 + 2 ]
if number-of-products = "many" [ set initial-products random 100 ]
create-existing-product
create-existing-projects
create-lone-tasks
create-#1
create-#9
create-#90
;; set current activity to avoid artefact
ask projects [ if count my-tasks-projects > 0 and count turtle-set [ tasklink-neighbors ] of my-tasks-projects > 0
[ let my-tasks-tasklinkneighbors turtle-set [ tasklink-neighbors ] of my-tasks-projects
set production-activity ( count link-set [ my-tasklinks ] of my-tasks-projects /
mean [ distance myself ] of my-tasks-tasklinkneighbors )
]
]
let lonetasks-activity sum [ count my-lonetasklinks ] of loneTasks
let total-prod-activity ( sum [production-activity] of projects + lonetasks-activity )
set community-prod-activity-ls replace-item 10 community-prod-activity-ls total-prod-activity
let total-cons-activity sum [consumption-activity] of products
set community-con-activity-ls replace-item 10 community-con-activity-ls total-cons-activity
reset-ticks
end
; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go
; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go
; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go ; Go
to go
set-bounties ;; contributors can set a bounty to their project if they wish
find-projects ;; contributors find projects - dependent on platform ON/OFF
find-tasks ;; contributors find tasks - not dependent on platform, this is where actual decision
;; to defo contribute is made
find-featured-tasks ;; 9s can find featured tasks if scenario is on
contribute-to-tasks ;; contributors regulate the number of tasks they have, and record contribute
drop-projects ;; contributors drop projects if lonely/unpopular/no tasks for them
make-and-lose-friends ;; friendships formed and broken
advertise-featured-tasks ;; projects/contrbutors decide which tasks they might want to 'feature'
finish-tasks ;; finished tasks improve their product a bit, and die
give-out-reward ;; projects give out reward and/or thanks when all their tasks are finshed
finished-projects ;; finsihed project improve their product or birth a new product
tasks-identified ;; creates new tasks from existing tasks, ie., find new ones by doing others
projects-die ;; projects 'die' if no contributors or tasks
calc-recent-activity ;; projects calculate recent activity
update-project-position ;; projects get closer or further from 9s depending on recent activity (platform dependent)
new-projects ;; if projects have high recent activity they might produce another project
;; 1 and 9 can also propose projects
consume-products ;; 90s find product, consume, products calc consumption-activity,
;; small chance of dying, small chance connection with consumer lost
update-product-position ;; product moves closer or further from 90s depening on recent popularity of it,
update-90s-and-9s-and-1s-positions ;; 1s and 9s move closer to their friends, 90s move closer to consumers of same products
products-die ;; products 'die' if no consumers, and compete if a one product community
entry ;; various rules for diff agents entry to community
exit ;; various rules for diff agents exit from community
change-breed ;; rules for agents changing breed
all-age ;; all agents tick on their age/time in comm variable
update-community-activity ;; calc history of prod and cons activity
;; some backstop stop conditions for model
if count #1s = 0 [ set time-with-no-#1s time-with-no-#1s + 1 ]
if count #9s = 0 [ set time-with-no-#9 time-with-no-#9 + 1 ]
if count #90s = 0 [ set time-with-no-#90s time-with-no-#90s + 1 ]
if count products = 0 [ set time-with-no-products time-with-no-products + 1 ]
if count t4sks + count loneTasks = 0 [ set time-with-no-tasks time-with-no-tasks + 1 ]
if ( time-with-no-#90s = 26 ) [ print "stop no #90s" print ticks stop ]
if ( time-with-no-#1s = 26 ) [ print "stop no #1s" print ticks stop ]
if ( time-with-no-#9 = 26 ) [ print "stop no #9" print ticks stop ]
if ( time-with-no-products = 26 ) [ print "stop no products" print ticks stop ]
if ( time-with-no-tasks = 26 ) [ print "stop no tasks" print ticks stop ]
;; backstop if too big / slow
if count #1s > 200 [ print "huge community" stop ]
if count #9s > 10000 [ print "huge community" stop ]
if count #90s > 10000 [ print "huge community" stop ]
tick
end
;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures
;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures
;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures;Setup Procedures
to create-existing-product
create-products initial-products [ set inter3st random num-interest-categories
set xcor -10
set ycor -25 + inter3st
set size 2
set color orange
set shape "box"
set volume random 100
set age 0
set consumption-history []
set mon-project []
]
end
to create-project
set count-new-projects count-new-projects
set num-tasks random 10 + 2
set production-history []
set reward-level random 100
ifelse random-float 1 < prop-of-projects-initially-private
[set is-private? true]
[set is-private? false]
ifelse random-float 1 < prop-of-projects-reward-subjective
[ set reward-type "subjective" ]
[ set reward-type "objective" ]
hatch-t4sks num-tasks [
set size 0.7
set color green
set shape "circle"
t4sk-set-typ3
set inter3st [inter3st] of myself
set time-required random-normal mean-time-required ( mean-time-required / 4 )
set modularity random max-modularity + 1
set age 0
set my-project myself
set featured? FALSE
]
set my-tasks-projects t4sks with [ my-project = myself ]
;; TODO missing in create existing projects
set current-contributors turtle-set [ tasklink-neighbors ] of my-tasks-projects
set size 2.5
set color green - 2
set shape "target"
set age 0
set likes-history []
ask t4sks with [my-project = myself ] [ set xcor [xcor] of myself
set ycor [ycor] of myself
set heading random 360
fd 1
]
end
to create-existing-projects
create-projects initial-projects [
create-project
set inter3st random num-interest-categories
ifelse random-float 1 < proportion-onplatform-projects
[set is-on-platform? true]
[set is-on-platform? false]
set xcor 5
set ycor -25 + inter3st
ask t4sks with [my-project = myself ] [ set xcor [xcor] of myself
set ycor [ycor] of myself
set heading random 360
fd 1
]
set my-product min-one-of products [ distance myself ]
create-projectproductlink-with my-product [ set color red ]
ask projectproductlink-neighbors [ set mon-project (list (projectproductlink-neighbors) ) ]
]
end
to create-lone-tasks
create-loneTasks initial-projects [ set inter3st random num-interest-categories
set xcor 0
set ycor -25 + inter3st
set size 0.7
set color yellow
set shape "circle"
set time-required random-normal mean-time-required ( mean-time-required / 4 )
set modularity random max-modularity + 1
set age 0
set typ3 random (num-skills - 1)
set my-product-L one-of products
]
end
to-report set-using-platform
;; is true iff platform-features is TRUE and if a random number between 0 and 1 is below the proportion of people using the platform
report platform-features and (random-float 1 < proportion-using-platform)
end
to create-#1
create-#1s initial-number-1s [ set interest random num-interest-categories
set xcor 18
set ycor -25 + interest
set size 1.5
set color red
set my-time 1 + random 40
set time my-time
set skill (n-of 3 (n-values num-skills [?]))
set using-platform? set-using-platform
set points 0
set thanks "not received"
set my-projects-1s (list (min-one-of projects [ distance myself ]) )
let my-projects-tasks
t4sks with [ member? ( [ my-project ] of self ) ( [my-projects-1s] of myself ) ]
if any? my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
[ let new-task$ my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
create-tasklinks-with new-task$ [ set color 3 ]
]
set my-tasks-1s tasklink-neighbors
set time my-time - sum [ modularity ] of tasklink-neighbors
if time > 0 [ create-lonetasklink-with min-one-of loneTasks [distance myself ] [set color 4]
set my-lone-tasks-1s lonetasklink-neighbors
]
set contribution-history-1s (n-values 10 [ round random-exponential 0.7 ] )
set my-total-contribution-1s count my-tasklinks
let new-friends other turtle-set [ tasklink-neighbors ] of my-tasks-1s
create-friendlinks-with n-of round ( count new-friends / 2 ) new-friends [set color red
set times-worked-together 1]
set my-friends friendlink-neighbors
]
end
to create-#9
create-#9s initial-number-9s [ set interest random num-interest-categories
set xcor ( random 6 ) + 19
set ycor -25 + interest
set size 1
set color blue
set my-time 1 + random 20
set time my-time
set skill (n-of 3 (n-values num-skills [?]))
set using-platform? set-using-platform
set i-used-featured? FALSE
set points 0
set thanks "not received"
set my-projects (list (min-one-of projects [ distance myself ]))
let my-projects-tasks
t4sks with [ member? ( [ my-project ] of self ) ( [my-projects] of myself ) ]
if any? my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
[ let new-task$ my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
create-tasklinks-with new-task$ [set color 3]
]
set my-tasks tasklink-neighbors
set time my-time - sum [ modularity ] of tasklink-neighbors
if time > 0 [ create-lonetasklink-with min-one-of loneTasks [distance myself ] [set color 4]
set my-lone-tasks lonetasklink-neighbors
]
set contribution-history-9s (n-values 10 [ round random-exponential 0.6 ] )
set my-total-contribution-9s count my-tasklinks
let new-friends other turtle-set [ tasklink-neighbors ] of my-tasks
create-friendlinks-with n-of round ( count new-friends / 2 ) new-friends [set color blue
set times-worked-together 1]
set my-friends friendlink-neighbors
]
;; once 1s and 9s created - projects can set their current contributors
ask projects [ set current-contributors turtle-set [ tasklink-neighbors ] of my-tasks-projects ]
end
to create-#90
create-#90s initial-number-90s [ ifelse number-of-products = "one"
[ set interest [ inter3st ] of one-of products + random 20 - 10
if interest > 50 [ set interest 50 ]
if interest < 0 [ set interest 0 ]
]
[ set interest random num-interest-categories ]
set xcor random 8 - 22
set ycor -25 + interest
set size 1
set color yellow
set skill (n-of 3 (n-values num-skills [?]))
set consumption 0
set using-platform? set-using-platform
create-consumerlink-with min-one-of products [ distance myself ]
ask consumerlink-neighbors [ if count my-consumerlinks > 0
[ set consumption-activity ( ( count my-consumerlinks / mean [ distance myself ] of consumerlink-neighbors ) *
( volume / ( mean [ volume ] of products + 1 ) )
)
] ]
]
end
to setup-globals
set #9s-left 0
set #90s-left 0
set new-#9s-total 0
set new-#90s-total 0
set #9s-left 0
set #90s-left 0
set new-#9s-total 0
set new-#90s-total 0
set new-#1-count 0
set products-consumed 0
set tasks-completed 0
set new-tasks-count 0
set new-products-count 0
set #9-to-#1-count 0
set #1-to-#9-count 0
set #9-left-no-interest 0
set #1-left-burnout 0
set time-with-no-#1s 0
set time-with-no-#9 0
set time-with-no-#90s 0
set new-#9-attracted-by-#90s 0
set projects-died 0
set loneTasksFinished 0
set count-new-projects 0
set product-had-no-consumer-so-left 0
set community-prod-activity-ls [0 0 0 0 0 0 0 0 0 0 0]
set community-con-activity-ls [0 0 0 0 0 0 0 0 0 0 0]
set num-skills 10
if platform-features = FALSE [ set chance-90-find-a-task chance-90-find-a-task / 2 ]
end
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures;Go Procedures
to set-bounties
;; if bounties is ON, tasks set a bounty (with some probability) to 10% of points of contributors to its project
;; contributors decrease their points accordingly
if reward-mechanism-2 = "bounties" [
ask t4sks [ let myProjectsPoints [ sum [ points ] of current-contributors ] of my-project
let avProjectsPoints mean [ sum [ points ] of current-contributors ] of projects
if count tasklink-neighbors = 0 and
random-float 1 < prob-set-a-bounty and
myProjectsPoints > avProjectsPoints [
set bounty 0.1 * myProjectsPoints
ask [ current-contributors ] of my-project [ set points points - (0.1 * points) ]
]
]
ask projects [ set total-bounty sum [ bounty ] of t4sks with [ my-project = myself ] ]
]
end
to-report project-distance
let noise? (
(not [ using-platform? ] of myself) or
(community-type = "offline") or
is-private?
)
let bounties? (
[ using-platform? ] of myself and
reward-mechanism-2 = "bounties" and
not is-private?
)
let reputation? (
[ using-platform? ] of myself and
reward-mechanism-2 = "reputation" and
not is-private?
)
let dist distance myself
if noise?
[ set dist dist + random max-noise - (max-noise / 2)]
if (bounties? and total-bounty != 0) [
let avgBounties
mean [ total-bounty ] of projects
if (avgBounties != 0) [
;; TODO: Is the attractive of a bounty proportional to the relation with the average?
;; should we take logarithms instead?
;; todo, should total bounties affect distance here? or should they go straight for bounties in tasks
set dist dist - dist * bountiesEffect * (total-bounty / avgBounties)
]
]
if (reputation?) [
let avgReputation
mean [ sum [ points ] of current-contributors ] of projects
let myReputation
sum [ points ] of current-contributors
if (avgReputation != 0) [
;; TODO: Is the attractive of a project due to its reputation proportional to the relation with the average?
;; should we take logarithms instead?
set dist dist - dist * reputationEffect * (myReputation / avgReputation)
]
]
report dist
end
to find-projects
ask #1s [ if time > 0
[ let other-projects projects with [ not member? self [ my-projects-1s ] of myself ]
let new-project min-one-of other-projects [ project-distance ]
if other-projects != nobody [ set my-projects-1s lput new-project my-projects-1s ]
]
]
ask #9s [ if time > 0
[ let other-projects projects with [ not member? self [ my-projects ] of myself ]
let new-project min-one-of other-projects [ project-distance ]
if other-projects != nobody and new-project != nobody
;; random number < prob / ( distance of new project / distance furthest project )
;; ie., relative closeness of new project increases chance of joining it
[ if random-float 1 < ( prob-9-decides-to-join-project / ( ( [ project-distance ] of new-project ) /
( [ project-distance ] of max-one-of projects [ project-distance ] )
)
)
[ set my-projects lput new-project my-projects ]
]
]
]
end
to find-tasks
; 1s find tasks that are in the projects they have found, with the right skills required
; they dont worry about thanks/points and friendship in joining tasks
ask #1s [ if time > 0 [ let my-projects-tasks t4sks with [ member? ( [ my-project ] of self ) ( [my-projects-1s] of myself ) ]
if any? my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
[ let new-task$ my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
create-tasklinks-with new-task$ [set color 3]
]
if ( not any? my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ])
[ let new-task$-2 one-of my-projects-tasks
if new-task$-2 != nobody [ create-tasklink-with new-task$-2 [set color 3] ]
]
set my-tasks-1s tasklink-neighbors
]
]
; 9s find tasks that are in the projects they have found, with the right skills required
; they are affected by thank/points and friendship in deciding to actually joing a task
; joiing a task is the point of deciding to make an actual contribution - once you have joined it is assumed you will contribute
ask #9s [ if time > 0 [ ; 9s first must calc their current feel-loved score to be used in decision
if reward-mechanism = "none" [ set feel-loved 0 ]
if reward-mechanism = "'thanks' only" [ if thanks = "not received" [ set feel-loved 0 ]
if thanks = "received from #9" [ set feel-loved 0.005 ]
if thanks = "received from #1" [ set feel-loved 0.01 ]
]
if reward-mechanism = "'points' only" [ set feel-loved 0
let personType random-float 1
if personType > 0.2 and points > median [ points ] of #9s [ set feel-loved 0.005 ]
if personType < 0.2 and points < median [ points ] of #9s [ set feel-loved 0.005 ]
]
if reward-mechanism = "both" [ let personType random-float 1
if thanks = "not received" [ set feel-loved 0 ]
if personType > 0.2 and points > median [ points ] of #9s [ set feel-loved 0.005 ]
if personType < 0.2 and points < median [ points ] of #9s [ set feel-loved 0.005 ]
if thanks = "received from #9" [ set feel-loved 0.005 ]
if thanks = "received from #1" [ set feel-loved 0.01 ]
]
let my-projects-tasks t4sks with [ member? ( [ my-project ] of self ) ( [my-projects] of myself ) ]
if any? my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
[ let new-task$ my-projects-tasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
;; 9 might be attracted to an appropriate tasks just by the bounty (but still needs to be in one of their projects and right skill
let aveBounty mean [ bounty ] of t4sks
let aveContributors mean [ count tasklink-neighbors ] of t4sks
ifelse any? new-task$ with [ ( ifelse-value ( count tasklink-neighbors != 0 ) [ bounty / count tasklink-neighbors ] [ bounty ] ) >
( aveBounty / aveContributors ) and random-float 1 < chance-9-chases-a-bounty ]
[ create-tasklink-with max-one-of new-task$ [ ifelse-value ( count tasklink-neighbors != 0 ) [ bounty / count tasklink-neighbors ] [ bounty ] ] [set color 3]
set my-tasks tasklink-neighbors
]
[
; using contribution-history-9s increases chance of contribution with prev contributions
; using feel-loved increases chance of contribution with thanks/points
; higher chance when there are contributors who are my friend, and when i have contributors who
; are my friend, i only look at these tasks
let contributors-to-new-task turtle-set [ tasklink-neighbors ] of new-task$
let contributors-to-new-tasks-that-are-my-friend
contributors-to-new-task with [ member? myself friendlink-neighbors ]
;; 9 goes for the taks with highest bounty / contributors
ifelse any? contributors-to-new-tasks-that-are-my-friend and contribution-history-9s != 0 and random-float 1 < chance-9-picks-tasks-with-friends
[ if ( random-float 1 < ( prob-9-contributes-to-friends-task + ( 0.01 * sum contribution-history-9s ) + feel-loved ) )
[ let mostBountyOfFriendsTask max-one-of turtle-set [ tasklink-neighbors ] of contributors-to-new-tasks-that-are-my-friend [ bounty / count tasklink-neighbors ]
create-tasklink-with mostBountyOfFriendsTask
[set color 3]
]
]
[ if contribution-history-9s != 0 [ if ( random-float 1 < ( prob-9-contributes-to-none-friend-task + ( 0.01 * sum contribution-history-9s ) + feel-loved ) )
[ create-tasklink-with max-one-of new-task$ [ ifelse-value ( count tasklink-neighbors != 0 ) [ bounty / count tasklink-neighbors ] [ bounty ] ] [set color 3] ] ]
]
set my-tasks tasklink-neighbors
]
]
]
]
;; find lone tasks - 1s with easily online and with some error offline
;; 9s with some error online and randomly for offline
ask #1s [ if community-type = "online" and time > 0
[ if any? loneTasks [ let new-loneTask min-one-of loneTasks [ distance myself ]
create-lonetasklink-with new-loneTask [set color 4]
set my-lone-tasks-1s lonetasklink-neighbors
]
]
if community-type = "offline" and time > 0
[ if any? loneTasks [ let new-loneTask min-one-of loneTasks [ distance myself + random 5 - 2.5 ]
create-lonetasklink-with new-loneTask [set color 4]
set my-lone-tasks-1s lonetasklink-neighbors
]
]
]
ask #9s [ if community-type = "online" and time > 0 and contribution-history-9s != 0
[ if any? loneTasks and random-float 1 < prob-9-decides-to-join-project + ( 0.01 * sum contribution-history-9s )
[ let new-loneTask min-one-of loneTasks [ distance myself + random 5 - 2.5 ]
create-lonetasklink-with new-loneTask [set color 4]
set my-lone-tasks lonetasklink-neighbors
]
]
if community-type = "offline" and time > 0 and contribution-history-9s != 0
[ if any? loneTasks and random-float 1 < prob-9-decides-to-join-project + ( 0.01 * sum contribution-history-9s )
[ create-lonetasklink-with one-of loneTasks [set color 4]
set my-lone-tasks lonetasklink-neighbors
]
]
]
end
to find-featured-tasks
;; 9s and 90s only? can find featured/advertised tasks directly. ie., they are not focusing so much on interest, but also skills required.
;; possible todos - only low contributors use featured needs service?
;; possible todo - some needs more likely to be found? age?
;; if the right scenario
if platform-features = TRUE and featured-needs? = TRUE
;; only 9s using TEEM
[ ask #9s with [ using-platform? = true ]
;; if they have time, and are active
[ if time > 0 and contribution-history-9s != 0
;; look at featured tasks and with some probability, make a connection to one i have skills for
[ let featuredTasks t4sks with [ featured? = TRUE ]
;; need to exlude tasks already joined? nope - nothing happens if you join twice
if any? featuredTasks and random-float 1 < prob-9-finds-featured-need
[ let new-FeaturedTask featuredTasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
if any? new-FeaturedTask [ create-tasklink-with one-of new-FeaturedTask [ set color 3 ]
set my-tasks tasklink-neighbors
;; the project then also becomes one of their projects?
let new-project [ my-project ] of new-FeaturedTask
set my-projects lput new-project my-projects
set i-used-featured? TRUE
]
]
]
]
ask #90s with [ using-platform? = true ]
;; to do? how does chance of 90 become 9 here, relate to chance in change breed
[ let featuredTasks t4sks with [ featured? = TRUE ]
if any? featuredTasks and random-float 1 < chance-90-find-a-task
[ let new-FeaturedTask featuredTasks with [ member? ( [ typ3 ] of self ) ( [ skill ] of myself ) ]
if any? new-FeaturedTask [ set breed #9s
set xcor ( random 6 ) + 19
set ycor -25 + interest
set size 1
set color blue
set my-time 1 + random 20
set time my-time
set points 0
set thanks "not received"
create-tasklink-with one-of new-FeaturedTask [ set color 3 ]
set my-tasks tasklink-neighbors
;; the project then also becomes one of their projects?
let new-project [ my-project ] of new-FeaturedTask
set my-projects (list (new-project))
set contribution-history-9s (list (0))
ask my-consumerlinks [die]
set #90-used-featured-needs #90-used-featured-needs + 1
set #90-to-#9-count #90-to-#9-count + 1
set i-used-featured? TRUE
]
]
]
]
end
to contribute-to-tasks
; 1s and 9s update time availability, if no time left, drop tasks
; then they update some records of contributions
ask #1s [ set time my-time - sum [ modularity ] of tasklink-neighbors - sum [ modularity ] of lonetasklink-neighbors
if time < 0 and count my-tasklinks > 1
[ ; need to pick tasks to drop
; 1/4 chance each it is less popular tasks, task with lots to do, task with least friends, or a lonetask
let chance random-float 1
if chance < 0.25
[ ask link-with ( min-one-of tasklink-neighbors [ xcor ] ) [die] ]
if chance >= 0.25 and chance < 0.5
[ ask link-with ( max-one-of tasklink-neighbors [ time-required ] ) [die] ]
if chance >= 5 and chance < 0.75
[ ask link-with ( min-one-of tasklink-neighbors
[ count tasklink-neighbors with [ member? [ myself ] of myself friendlink-neighbors ] ] ) [die]
]
if chance >= 0.75
[ if count lonetasklinks > 0 [ ask one-of lonetasklinks [ die ] ] ]
set #1-dropped-a-task #1-dropped-a-task + 1
]
set time my-time - sum [ modularity ] of tasklink-neighbors - sum [ modularity ] of lonetasklink-neighbors
if count my-tasklinks > 0 [ set my-tasks-1s tasklink-neighbors
set my-lone-tasks-1s lonetasklink-neighbors
set contributions-made-by-1s contributions-made-by-1s + count tasklink-neighbors + count lonetasklink-neighbors
set time-contributed-by-1s time-contributed-by-1s + ( my-time - time )
]
set contribution-history-1s lput ( count my-tasklinks + count my-lonetasklinks ) contribution-history-1s
if length contribution-history-1s > 10 [ set contribution-history-1s but-first contribution-history-1s ]
set my-total-contribution-1s my-total-contribution-1s + ( count my-tasklinks + count my-lonetasklinks )
]
ask #9s [ set time my-time - sum [ modularity ] of tasklink-neighbors - sum [ modularity ] of lonetasklink-neighbors
if time < 0 and count my-tasklinks > 1
[ let chance random-float 1
if chance < 0.25
[ ask link-with ( min-one-of tasklink-neighbors [ xcor ] ) [die] ]
if chance >= 0.25 and chance < 0.5
[ ask link-with ( max-one-of tasklink-neighbors [ time-required ] ) [die] ]
if chance >= 0.5 and chance < 0.75
[ ask link-with ( min-one-of tasklink-neighbors
[ count tasklink-neighbors with [ member? [ myself ] of myself friendlink-neighbors ] ] ) [die]
]
if chance >= 0.75
[ if count lonetasklinks > 0 [ ask one-of lonetasklinks [ die ] ] ]
set #9-dropped-a-task #9-dropped-a-task + 1
]
set time my-time - sum [ modularity ] of tasklink-neighbors - sum [ modularity ] of lonetasklink-neighbors
if count my-tasklinks > 0 [ set my-tasks tasklink-neighbors
set my-lone-tasks lonetasklink-neighbors
set contributions-made-by-9s contributions-made-by-9s + count tasklink-neighbors + count lonetasklink-neighbors
set time-contributed-by-9s time-contributed-by-9s + ( my-time - time )
]
if contribution-history-9s = 0 [ set contribution-history-9s (list (0)) ]
set contribution-history-9s lput ( count my-tasklinks + count my-lonetasklinks ) contribution-history-9s
if length contribution-history-9s > 10 [ set contribution-history-9s but-first contribution-history-9s ]
set my-total-contribution-9s my-total-contribution-9s + ( count my-tasklinks + count my-lonetasklinks )
]
; task reduce their time by their contriubutors * modularity
ask t4sks [ set time-required time-required - (modularity * count tasklink-neighbors) ]
ask loneTasks [ set time-required time-required - (modularity * count lonetasklink-neighbors) ]
; projects reset their current contributors
ask projects [ set my-tasks-projects t4sks with [ my-project = myself ]
set current-contributors turtle-set [ tasklink-neighbors ] of my-tasks-projects
]
end
to drop-projects
; 1s drop a project and its tasks if it is lonely / unpopular
ask #1s [ if any? ( turtle-set my-projects-1s ) with
[ all? my-tasks-projects [ ( turtle-set tasklink-neighbors = turtle-set myself ) OR
( turtle-set tasklink-neighbors = nobody )
]
]
and random-float 1 < prob-1-drop-lonely-project [
let lonely-projects ( turtle-set my-projects-1s ) with
[ all? my-tasks-projects [ ( turtle-set tasklink-neighbors = turtle-set myself OR
turtle-set tasklink-neighbors = nobody )
]
]
let lonely-unpopular-project one-of lonely-projects with
; distance of project increase chance it being picked to drop
; especially if xcor less than 0 - ie., pretty unpopular
[ random-float 1 < ( [ xcor ] of myself - xcor / 17 - (- 4) ) ]
let lonely-unpopular-tasks [ my-tasks-projects ] of lonely-unpopular-project
set my-projects-1s remove lonely-unpopular-project my-projects-1s
set #1-dropped-a-project #1-dropped-a-project + 1
ask lonely-unpopular-tasks [ ask my-tasklinks [die] ]
set my-tasks-1s tasklink-neighbors
set #1-dropped-a-task #1-dropped-a-task + (count lonely-unpopular-tasks )
]
]
; 9s drop a project and its tasks if it is lonely / unpopular (also 10 times more likely to do this)
ask #9s [ if any? ( turtle-set my-projects ) with
[ all? my-tasks-projects [ ( turtle-set tasklink-neighbors = turtle-set myself ) OR
( turtle-set tasklink-neighbors = nobody )
]
]
and random-float 1 < prob-9-drop-a-lonely-or-no-tasks-project [
let lonely-projects ( turtle-set my-projects ) with
[ all? my-tasks-projects [ ( turtle-set tasklink-neighbors = turtle-set myself OR
turtle-set tasklink-neighbors = nobody )
]
]
let lonely-unpopular-project one-of lonely-projects with
[ random-float 1 < ( [ xcor ] of myself - xcor / 17 - (- 4) ) ]
let lonely-unpopular-tasks [ my-tasks-projects ] of lonely-unpopular-project
set my-projects remove lonely-unpopular-project my-projects
set #9-dropped-a-project #9-dropped-a-project + 1
ask lonely-unpopular-tasks [ ask my-tasklinks [die] ]
set my-tasks tasklink-neighbors
set #9-dropped-a-task #9-dropped-a-task + (count lonely-unpopular-tasks )
]
]
; with a certain chance 9s drop projects if they have no tasks in them
ask #9s [ if count ( turtle-set my-projects ) with [ not member? self [ [ my-project ] of my-tasks ] of myself ] > 0 and
random-float 1 < prob-9-drop-a-lonely-or-no-tasks-project
[ let projects-to-drop ( turtle-set my-projects ) with [ not member? self [ [my-project] of my-tasks ] of myself ]
set my-projects remove one-of projects-to-drop my-projects
set #9-dropped-a-project #9-dropped-a-project + 1
]
]