-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode Skripsi Konflik Gajah manusia + links alternate v46.nlogo
4641 lines (4122 loc) · 137 KB
/
Code Skripsi Konflik Gajah manusia + links alternate v46.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 [matrix rnd py dbscan]
breed[elephants elephant]
breed[people person]
breed[plants plant]
globals [
ada-seminar?
collective-decision?
kolektivitas
tanggal-seminar
saldo-kolektif
pengetahuan-agregat
kesadaran-agregat
collective-fence-cost
global-matrix
skema-cicilan
titik-serangan-gajah
patches-diserang-gajah
konflik-bulanan
cicilan-berlaku
pengetahuan-of-dominance-group
dominance-group
member-of-dominance-group
;patches-tidak-diserang-gajah
]
people-own[
group
any-people-nearby?
people-nearby
mean-kedekatan
pekerjaan
pengetahuan
df-pengetahuan
df-pengetahuan-old
kesadaran
conservation-attitude
decision-individual-buy-fence
saldo
lahan
jumlah-lahan
punya-lahan-ilegal?
jumlah-lahan-ilegal
jumlah-lahan-produktif
jumlah-lahan-nonproduktif
keputusan-tanam
last-decision-made
estimated-cost-pagar-listrik
perceived-benefits
bayesian-beliefs
decision-history
beban-premi
lahan-saya-diserang?
membantu-lahan-warga?
last-tick-membantu-lahan-warga
orang-yang-dibantu
lahan-yang-dibantu
attitudes-pagar-listrik
jumlah-premi-dibayar
lagi-nyicil
time-adopt
my-patch-last-reduced-damage-history
my-patch-last-reduced-damage
]
plants-own[
jenis-tanaman
waktu-panen
potential-income
ownership
umur-tanaman
yields
siklus-panen
yields-saat-panen
price
sedang-panen
kondisi-tanaman
last-adjusted-attack-damage
reduced-damage
palatability
]
patches-own [
kepemilikan
lahan-produktif?
jenis-lahan
dikunjungi-gajah?
waktu-dikunjungi-gajah
frekuensi-lahan-diserang
jumlah-warga-membantu
dipasangi-pagar-listrik?
probabilitas-diserang
perimeter-length
last-reduced-damage-history
waktu-dikunjungi-gajah-history
]
links-own [
kedekatan
belong-to
interaction-type
jumlah-bertemu]
to setup
ca
reset-ticks
create-people num-people [setxy random-xcor random-ycor
move-to-empty-patches
set membantu-lahan-warga? False ] ;cari tahu proporsi pekerjaan disana berapa persen berapa persen
setup-pekerjaan-dan-lahan
update-color
;pola-kolektivitas
create-link
if innitial-adopter = True [setup-innitial-adopter]
ask patches [set last-reduced-damage-history [] set waktu-dikunjungi-gajah-history [] ]
if frontier-scenario = True [setup-frontier-innitial-adopter]
end
to setup-pekerjaan-dan-lahan
ask people [
set pekerjaan "petani"
set decision-individual-buy-fence false
set perceived-benefits random-normal 0 1
set decision-history []
set my-patch-last-reduced-damage-history []
set saldo random-normal 200000000 1000000
let k random 100
ifelse k <= proporsi-pro/kontra [set attitudes-pagar-listrik "Pro" set pengetahuan (50 + random 35)][set attitudes-pagar-listrik "Kontra" set pengetahuan (50 - random 15)]
; set attitudes-pagar-listrik one-of ["Pro" "Kontra"]
set conservation-attitude one-of ["pro" "kontra"]
ifelse conservation-attitude = "pro" [set kesadaran 60 + random 15][set kesadaran 40 - random 15]
; ifelse attitudes-pagar-listrik = "pro"
; [set pengetahuan (50 + random 25)][set pengetahuan (50 - random 35)]
]
ask people with [pekerjaan = "petani"][
let prob [0.2 0.4 0.4]
set punya-lahan-ilegal? one-of [True False]
set keputusan-tanam (first rnd:weighted-one-of-list [["padi" .2] ["karet" .3] ["sawit" .5] ] [[p] -> last p ])
ask patches in-radius 2 [
ifelse [pxcor] of self < min [pxcor] of patches + (1 - proporsi-lahan-legal) * abs( min [pxcor] of patches)
[set jenis-lahan "illegal"][set jenis-lahan "legal"]
set dikunjungi-gajah? False
set probabilitas-diserang random-float 10
set pcolor green set kepemilikan myself set dipasangi-pagar-listrik? False ; myself refers to the caller (yang nge ask pertama kali) which is the people dgn pekerjaan petani
let z random 10
if z < kekayaan-agrikultural [ if not any? plants-here = True [sprout-plants 1 [
set kondisi-tanaman 100
set shape "plant"
set jenis-tanaman [keputusan-tanam] of ([kepemilikan] of patch-here)
set ownership ([kepemilikan] of patch-here)] ] ] ; tanaman akan ngambil value dari patch yang dia pijak
]
set lahan [self] of patches with [kepemilikan = myself] ;assigning me (tanaman dengan kepemilikan myself) to lahan
set jumlah-lahan count patches with [kepemilikan = myself]
set jumlah-lahan-produktif count patches with [kepemilikan = myself and lahan-produktif? = True]
set jumlah-lahan-nonproduktif count patches with [kepemilikan = myself and lahan-produktif? = False]
]
ask plants with [ownership != [kepemilikan] of patch-here][die] ;agar tidak ada tanaman yang tumpang tindih di satu lahan
update-palatability
end
to create-link
ask people [
create-links-with other people[set belong-to myself set jumlah-bertemu 0]
]
ask links [ set kedekatan (10 + random 9) ]
end
to setup-innitial-adopter
ask n-of (proportion-of-innitial-adopter * num-people) people [
set decision-individual-buy-fence True
set kesadaran 20 + random 15
set pengetahuan 70 + random 15
ask patches with [kepemilikan = myself][ set dipasangi-pagar-listrik? True ]
]
end
to setup-frontier-innitial-adopter
ask rnd:weighted-n-of (proportion-of-innitial-adopter * num-people) people [((max [xcor] of people - xcor) / 2 * max [xcor] of people)]
[set decision-individual-buy-fence True
set kesadaran 20 + random 15
set pengetahuan 70 + random 15
ask patches with [kepemilikan = myself][ set dipasangi-pagar-listrik? True ]
]
end
to go
;konflik gajah
konflik-gajah
;membantu-lahan-warga
gulung-tikar
;go procedure manusia
manusia-bergerak
seminar
proses-keputusan-menanam
individual-buy-fence2
if pagar-listrik-kolektif = True [
if collective-type = "global consensus"
[create-clusters
kolektif-buying-fence ]
if collective-type = "subgrouping"
[create-clusters2
skema-cicil-subgrouping]
]
;go procedure tanaman
pertumbuhan-tanaman
hitung-potential-income-tanaman
panen-tanaman
update-color
; set konflik-bulanan lput patches-diserang-gajah konflik-bulanan
tick
if count patches with [kepemilikan != 0 and dipasangi-pagar-listrik? = True] >= 0.9 * count patches with [kepemilikan != 0]
[stop]
end
to go-non-stop
;konflik gajah
konflik-gajah
;membantu-lahan-warga
gulung-tikar
;go procedure manusia
manusia-bergerak
seminar
proses-keputusan-menanam
individual-buy-fence2
kolektif-buying-fence
;go procedure tanaman
pertumbuhan-tanaman
hitung-potential-income-tanaman
panen-tanaman
update-color
; set konflik-bulanan lput patches-diserang-gajah konflik-bulanan
tick
end
to manusia-bergerak
ask people [
if last-tick-membantu-lahan-warga < (ticks + 1) [set membantu-lahan-warga? False] ;variable membantu lahan orang dari prosedur membantu-lahan-warga
set people-nearby one-of other people in-radius radius-interaksi
; ifelse people-nearby = nobody and any-people-nearby? = True [fd 3 rt random 120 lt random 120 set people-nearby one-of other people in-radius radius-interaksi][
ifelse people-nearby = nobody [ set any-people-nearby? False][ifelse people-nearby = nobody and any-people-nearby? = True [ set any-people-nearby? False ]
[set any-people-nearby? True]]
if any-people-nearby? = True
[
move-to people-nearby
sharing-value ;sharing value disini
membangkitkan-kesadaran ;membangkitkan-kesadaran disini
fd 1 rt random 120 lt random 120
let z [who] of self
let x [who] of people-nearby
ask link z x [
if kedekatan > 200 [set kedekatan 200]
set jumlah-bertemu jumlah-bertemu + 1
set interaction-type one-of ["positive" "negative"]
ifelse [attitudes-pagar-listrik] of turtle x = [attitudes-pagar-listrik] of turtle z
[ifelse interaction-type = "Positive" [set kedekatan kedekatan + (5 / abs(kedekatan + 1))][set kedekatan kedekatan + (0.2 / abs(kedekatan + 1)) ] ]
[ifelse interaction-type = "positive"
[set kedekatan kedekatan + (1 / abs(kedekatan + 1))][set kedekatan kedekatan - (1 / abs(kedekatan + 1))]]
]
]
fd 1 rt random 120 lt random 120
]
end
to sharing-value ;evaluate pola pertambahan pengetahuan nya
;value adjuster to maksimum value and minimum value
ask people with [attitudes-pagar-listrik = "Pro"]
[ if pengetahuan > 200 [set pengetahuan 200]]
ask people with [attitudes-pagar-listrik = "Kontra"]
[ if pengetahuan <= -200 [set pengetahuan -200]]
ask people [
if people-nearby = nobody and any-people-nearby? = True [ set any-people-nearby? False ]]
ask people [
ifelse pengetahuan >= 95 or pengetahuan <= 5 [fd 0][
if any-people-nearby? = True
[let value [kedekatan] of link [who] of self [who] of people-nearby
ifelse value > 70 ;(70 = treshold kedekatan, bisa diganti) ;statement pertama kalo deket ; statement kedua kalo ga deket
[ifelse [attitudes-pagar-listrik ] of people-nearby = [attitudes-pagar-listrik ] of self
[ifelse [attitudes-pagar-listrik] of self = "Pro"
[set pengetahuan pengetahuan + (inkremen4)
ask people-nearby [set pengetahuan pengetahuan + inkremen4]]
[set pengetahuan pengetahuan - (inkremen5)
ask people-nearby [set pengetahuan pengetahuan - inkremen5]]
] ;statement kalau sama sama pro atau sama sama kontra
[ifelse [attitudes-pagar-listrik] of self = "Pro" ;statement kalau berbeda pandangan tpai masih deket
[set pengetahuan pengetahuan - (inkremen7)
ask people-nearby [set pengetahuan pengetahuan + inkremen7] ] ;kalau self nya pro dan people-nearby nya kontra
[set pengetahuan pengetahuan + (inkremen6 )
ask people-nearby [set pengetahuan pengetahuan - inkremen6]] ;kalau self nya kontra dan people-nearby nya pro
]
]
[ifelse [attitudes-pagar-listrik ] of people-nearby = [attitudes-pagar-listrik ] of self
[ifelse [attitudes-pagar-listrik] of self = "Pro"
[set pengetahuan pengetahuan + (inkremen6 )
ask people-nearby [set pengetahuan pengetahuan + inkremen6]]
[set pengetahuan pengetahuan - (inkremen7 )
ask people-nearby [set pengetahuan pengetahuan - inkremen7]]
]
[ifelse [attitudes-pagar-listrik] of self = "Pro"
[set pengetahuan pengetahuan + (inkremen4)
ask people-nearby [set pengetahuan pengetahuan - inkremen4]]
[set pengetahuan pengetahuan - (inkremen5)
ask people-nearby [set pengetahuan pengetahuan + inkremen5]]
]
]
]
]
]
; memodelkan variable social influence --> ketika orang memiliki pengaruh social yang tinggi, maka orang akan cenderung percaya
;evaluate social setting nya (kedekatan)
;evaluate attittudes nya dia dan orang yang paling dekat
; kalo kedekatan nya tinggi --> value nya akan ngikut si kedekatan tinggi
;kalo kedekatan nya rendah --> value nya akan berlawanan dengan si kedekatan rendah
end
to membangkitkan-kesadaran
ask people [
;skenario : kedekatan
; skenario kesadaran tinggi dan rendah
;kalo deket :
; tinggi ketemu tinggi --> dua dua nya nambah
; tinggi ketemu rendah ---> kompromi yang pro akan ngurang yang kontra akan nambah
; kalo gadeket : case nya sama kayak deket tapi inkremen nya ga gede
if people-nearby = nobody and any-people-nearby? = True [ set any-people-nearby? False ]
;set people-nearby one-of people in-radius 8
if any-people-nearby? = True [
let k [kedekatan] of link [who] of self [who] of people-nearby
ifelse kesadaran >= 95 or kesadaran <= 5 [fd 0 ] [
ifelse k > 70
[;kalo deket
ifelse [conservation-attitude] of self = [conservation-attitude] of people-nearby ; menanyakan apakah conservation attitudes nya sama aau beda
[ ifelse [conservation-attitude] of self = "pro"
;kalo sama sama pro
[set kesadaran kesadaran + 2
ask people-nearby [
set kesadaran kesadaran + 2 ]
]
;kalo sama sama kontra
[set kesadaran kesadaran - 2
ask people-nearby [
set kesadaran kesadaran - 2]
]
]
[ifelse [conservation-attitude] of self = "pro"
[;kalo saya pro dan dia kontra
set kesadaran kesadaran - 1
ask people-nearby [set kesadaran kesadaran + 1]
]
[;kalo saya kontra dia pro
set kesadaran kesadaran + 1
ask people-nearby [set kesadaran kesadaran - 1]
]
]
]
[;kalo gadeket
ifelse [conservation-attitude] of self = [conservation-attitude] of people-nearby ; menanyakan apakah conservation attitudes nya sama aau beda
[ ifelse [conservation-attitude] of self = "pro"
;kalo sama sama pro
[set kesadaran kesadaran + 1
ask people-nearby [
set kesadaran kesadaran + 1 ]
]
;kalo sama sama kontra
[set kesadaran kesadaran - 1
ask people-nearby [
set kesadaran kesadaran - 1]
]
]
[ifelse [conservation-attitude] of self = "pro"
[;kalo saya pro dan dia kontra
set kesadaran kesadaran - .5
ask people-nearby [set kesadaran kesadaran + .5]
]
[;kalo saya kontra dia pro
set kesadaran kesadaran + .5
ask people-nearby [set kesadaran kesadaran - .5]
]
]
]
]
]
]
;ask people [
; if any? patches in-radius 20 with [dikunjungi-gajah? = True and dipasangi-pagar-listrik? = True] = True
; [let B patches in-radius 20 with [dikunjungi-gajah? = True and dipasangi-pagar-listrik? = True]
; ask B [count plants-here with [last-adjusted-attack-damage < 10]]
; let C count B with [last-adjusted-attack-damage < 10]
; set kesadaran kesadaran + (2 * C)
; ]
end
to seminar ; cari jurnal mengenai pengaruh penyuluhan
ifelse ticks mod frekuensi-seminar != 0 [set ada-seminar? false]
[if ticks != 0
[set ada-seminar? true
; set tanggal-seminar lput (ticks) tanggal-seminar
ask people [
let r random 10 ; kehadiran by random occurences
if r >= 8 [
set pengetahuan pengetahuan + pengetahuan-seminar] ; benefit seminar
]
]
]
end
to pertumbuhan-tanaman
ask plants [set umur-tanaman (umur-tanaman + 1)]
ask plants with [jenis-tanaman = "sawit"][
if umur-tanaman > 1 and umur-tanaman mod 365 = 0 [
ask ownership [
set saldo saldo - sawit-expenditure]
]
]
ask plants with [jenis-tanaman = "karet"][
if umur-tanaman > 1 and umur-tanaman mod 365 = 0 [
ask ownership [
set saldo saldo - karet-expenditure]
]
]
ask plants with [ownership = nobody][die]
end
to hitung-potential-income-tanaman
ask plants with [jenis-tanaman = "sawit"] [set yields 2 * umur-tanaman + 1] ;revisit
ask plants with [jenis-tanaman = "padi"] [set yields umur-tanaman + 7] ;revisit
ask plants with [jenis-tanaman = "karet"] [set yields (2 * umur-tanaman) + 7] ;revisit
ask plants with [jenis-tanaman = "sawit"] [set yields-saat-panen 800 * 5 + random 500] ;revisit
ask plants with [jenis-tanaman = "padi"] [set yields-saat-panen 5800 * 5 + random 100] ;revisit
ask plants with [jenis-tanaman = "karet"] [set yields-saat-panen 150 * 5] ;revisit
ask people [ set decision-history lput calculate-total-losses decision-history ]
end
to panen-tanaman ;setelah panen maka income direset menjadi nol; untuk mereset butuh variable sedang-panen?
ask plants with [ownership != nobody] [
if jenis-tanaman = "padi" [
ifelse umur-tanaman mod siklus-panen-padi = 0 [
if ticks != 0
[set sedang-panen true
set waktu-panen ticks
set potential-income yields-saat-panen * 5000 * kondisi-tanaman * .01
ask ownership [set saldo (saldo + [potential-income] of myself)]
set yields 0
die ]
]
[set sedang-panen false
set potential-income 0]
]
if jenis-tanaman = "sawit" [
ifelse umur-tanaman mod siklus-panen-sawit = 0 [
if ticks != 0
[set sedang-panen true
set waktu-panen ticks
set potential-income yields-saat-panen * 1700 * kondisi-tanaman * .01
ask ownership [set saldo (saldo + [potential-income] of myself)]
set yields 0]
]
[set sedang-panen false
set potential-income 0]
]
if jenis-tanaman = "karet" [
ifelse umur-tanaman mod siklus-panen-karet = 0 [
if ticks != 0
[set sedang-panen true
set waktu-panen ticks
set potential-income yields-saat-panen * 11000 * kondisi-tanaman * .01
ask ownership [set saldo (saldo + [potential-income] of myself)]
set yields 0]
]
[set sedang-panen false
set potential-income 0]
]
]
; ask people [ set saldo (saldo + [potential-income] of plants-on lahan) ]
; ask people [set saldo (saldo + sum ([potential-income] of plants with [ownership = myself])) ] ; solved
ask plants with [jenis-tanaman = "padi"][set palatability 3]
end
to proses-keputusan-menanam
ask people [
set jumlah-lahan-nonproduktif (count patches with [kepemilikan = myself and not any? plants-here = True])
set jumlah-lahan-produktif (jumlah-lahan - jumlah-lahan-nonproduktif)
let capital-cost-sawit sawit-expenditure
let capital-cost-karet karet-expenditure
let capital-cost-padi padi-expenditure
let decision-beli (list "sawit" "karet" "padi")
ifelse keputusan-tanam = 0
[; set keputusan-tanam one-of decision-beli
;set last-decision-made ticks
] ;ketika desicion dibuat, maka akan diberi buffer beberapa ticks sebelum petani mengubah keputusan nya
[if ticks > (holding-decision-tanam + last-decision-made)
[set last-decision-made (ticks)
set keputusan-tanam one-of decision-beli
]]
if jumlah-lahan-produktif = 0 [set keputusan-tanam 0
set keputusan-tanam one-of decision-beli]
if (keputusan-tanam = "sawit" and keputusan-tanam != "karet" and keputusan-tanam != "padi")
[ if saldo > (sawit-expenditure + cash-reserve)
[let k patches with [kepemilikan = myself and lahan-produktif? = False and (not any? plants-here = True)]
if jumlah-lahan-nonproduktif != 0
[ set saldo (saldo - sawit-expenditure)
ask one-of k [
sprout-plants 1 [
set jenis-tanaman "sawit" set kondisi-tanaman 100 set ownership [kepemilikan] of myself
ask patch-here [set lahan-produktif? True]
]]]
]
]
if (keputusan-tanam = "karet" and keputusan-tanam != "sawit" and keputusan-tanam != "padi")
[ if saldo > (karet-expenditure + cash-reserve)
[let k patches with [kepemilikan = myself and lahan-produktif? = False and (not any? plants-here = True)]
if jumlah-lahan-nonproduktif != 0
[set saldo (saldo - karet-expenditure)
ask one-of k [ sprout-plants 1 [
set jenis-tanaman "karet" set kondisi-tanaman 100 set ownership [kepemilikan] of myself
ask patch-here [set lahan-produktif? True]
]] ]]
]
if (keputusan-tanam = "padi" and keputusan-tanam != "karet" and keputusan-tanam != "sawit")
[ if saldo > (padi-expenditure + cash-reserve)
[let k patches with [kepemilikan = myself and lahan-produktif? = False and (not any? plants-here = True)]
if jumlah-lahan-nonproduktif != 0
[set saldo (saldo - padi-expenditure)
ask one-of k [ sprout-plants 1 [
set jenis-tanaman "padi" set kondisi-tanaman 100 set ownership [kepemilikan] of myself
ask patch-here [set lahan-produktif? True]
]]]
]]
set jumlah-lahan-produktif count patches with [kepemilikan = myself and lahan-produktif? = True]
]
update-palatability
end
to update-palatability
ask plants with [jenis-tanaman = "padi"][set palatability 3]
ask plants with [jenis-tanaman = "sawit"][set palatability 2]
ask plants with [jenis-tanaman = "karet"][set palatability 1]
end
to update-color
ask people [set jumlah-lahan-nonproduktif (count patches with [kepemilikan = myself and not any? plants-here = True])
set jumlah-lahan count patches with [kepemilikan = myself]
set jumlah-lahan-produktif count patches with [kepemilikan = myself and lahan-produktif? = True]
;set jumlah-lahan-nonproduktif count patches with [kepemilikan = myself and lahan-produktif? = False]
set jumlah-lahan-produktif (jumlah-lahan - jumlah-lahan-nonproduktif)]
set patches-diserang-gajah count patches with [dikunjungi-gajah? = True and waktu-dikunjungi-gajah = ticks]
ask patches with [kepemilikan != 0] [
ifelse not any? plants-here = True
[set pcolor brown set lahan-produktif? False]
[ifelse jenis-lahan = "legal" [set pcolor green set lahan-produktif? True][set pcolor green + 7 set lahan-produktif? True] ]
]
ask patches [
if dikunjungi-gajah? = True [set pcolor pink]
]
if ticks >= 1 [
ask patches with [kepemilikan != 0] [ ifelse waktu-dikunjungi-gajah < ticks
[ set dikunjungi-gajah? False][set dikunjungi-gajah? True] ]
]
ask plants with [jenis-tanaman = "padi"][set shape "plant" set color red set siklus-panen siklus-panen-padi set price 4200 ]
ask plants with [jenis-tanaman = "sawit"][set shape "plant" set color cyan set siklus-panen siklus-panen-sawit set price 3000]
ask plants with [jenis-tanaman = "karet"][set shape "plant"set color brown set siklus-panen siklus-panen-karet set price 7200]
ask patches with [kepemilikan != 0] [if dikunjungi-gajah? = True [
set frekuensi-lahan-diserang frekuensi-lahan-diserang + 1]
]
;update value conservation attitudes
ask people [
ifelse pengetahuan > 50 [set attitudes-pagar-listrik "Pro"][set attitudes-pagar-listrik "Kontra"]
if attitudes-pagar-listrik = "Pro" [set color white]
if attitudes-pagar-listrik = "Kontra" [set color red]
]
ask plants [if kondisi-tanaman <= 10 [ask patch-here [set lahan-produktif? False] die ]]
ask patches [
if dikunjungi-gajah? = True and kepemilikan = 0 [set pcolor black]
]
end
to membantu-lahan-warga
ask people [
ifelse count patches with [kepemilikan = myself and dikunjungi-gajah? = True] = 0
[set lahan-saya-diserang? False][set lahan-saya-diserang? True]]
if patches-diserang-gajah > 0
[
ask patches with [dikunjungi-gajah? = True and kepemilikan != 0 and dipasangi-pagar-listrik? = False][
ask [kepemilikan] of self [
move-to myself
ask my-links with [kedekatan > solidaritas-kedekatan and link-length < 2 * radius-interaksi]
[ask other-end [
ifelse decision-individual-buy-fence = False [
if ((membantu-lahan-warga? = False and lahan-saya-diserang? = False ))
[
set membantu-lahan-warga? True
set orang-yang-dibantu [other-end] of myself
move-to orang-yang-dibantu
set lahan-yang-dibantu patch-here
set last-tick-membantu-lahan-warga ticks
]]
[
set membantu-lahan-warga? True
set orang-yang-dibantu [other-end] of myself
move-to orang-yang-dibantu
set lahan-yang-dibantu patch-here
set last-tick-membantu-lahan-warga ticks
]
]
]
]
set jumlah-warga-membantu count people-here
]
]
;perlu revisit lagi karena orang yang ingin membantu belum sampai datang ke patch nya melainkan hanya datang ke orang yang butuh bantuan saja
;issue kedua --> orang yang dibantu masih beda patch dengan orang yang dibantuin lahan nya
end
to konflik-gajah ;evaluasi : gajah nya nyerang border aja, gajah nya nyerang several at a time sama perlu dicaritahu gimana caranya si gajah cuma bisa nyerang border
ask plants [if [dikunjungi-gajah?] of patch-here = False[set last-adjusted-attack-damage 0]]
ask plants [if [dipasangi-pagar-listrik?] of patch-here = True [set last-adjusted-attack-damage 0]]
let rate random-normal 0 1
if rate < rate-serangan-gajah [
let X count patches with [lahan-produktif? = True and (any? neighbors4 with [pcolor = black or pcolor = brown ])]
ifelse jumlah-titik-serangan-gajah >= X [set titik-serangan-gajah X][set titik-serangan-gajah jumlah-titik-serangan-gajah]
ask rnd:weighted-n-of titik-serangan-gajah patches with [any? plants-here = True and (any? neighbors4 with [pcolor = black or pcolor = brown ])] [((max-pxcor - pxcor) / 2 * max-pxcor) * item 0 [palatability] of plants-here]
[
set dikunjungi-gajah? True
set frekuensi-lahan-diserang frekuensi-lahan-diserang + 1
set waktu-dikunjungi-gajah ticks
ask plants-here [
let attack-severity (10 + one-of [20 50 70 90])
ifelse dipasangi-pagar-listrik? = True
[set last-adjusted-attack-damage 0
serang-sebelahnya
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage)]
]
[ membantu-lahan-warga
let P count people-here ;calculating efek bantuan orang terhadap severity rate tumbuhan
set reduced-damage efek-bantuan-orang * P
ifelse (attack-severity - reduced-damage) > 0 [set last-adjusted-attack-damage (attack-severity - reduced-damage)][set last-adjusted-attack-damage 0]
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage)]
]
]
; if waktu-dikunjungi-gajah < ticks + 1
; [ set dikunjungi-gajah? False]
]
]
ask patches [ifelse any? plants-here = True
[set last-reduced-damage-history lput item 0 [last-adjusted-attack-damage] of plants-here last-reduced-damage-history
if dikunjungi-gajah? = True [set waktu-dikunjungi-gajah-history lput waktu-dikunjungi-gajah waktu-dikunjungi-gajah-history ]]
[set last-reduced-damage-history lput 0 last-reduced-damage-history ]
]
ask people [set my-patch-last-reduced-damage-history lput sum [last last-reduced-damage-history] of patches with [kepemilikan = myself] my-patch-last-reduced-damage-history ]
ask people [set my-patch-last-reduced-damage sum [last last-reduced-damage-history] of patches with [kepemilikan = myself] ]
end
to serang-sebelahnya ;revisit --> ganti yang diserang jadi lahan orang terdekat ; problem --> bukan rekursif tapi patch akan memilih 2 patch lain ;bukan 1 patch --> milih 1 --> milih 1
if any? other patches in-radius 6 with [(pcolor = green or pcolor = 62) and kepemilikan != [kepemilikan] of myself and (any? other patches in-radius 1 with [pcolor = black or pcolor = brown])] [
ask one-of other patches in-radius 6 with [(pcolor = green or pcolor = 62) and kepemilikan != [kepemilikan] of myself and (any? other patches in-radius 1 with [pcolor = black or pcolor = brown])]
; if any? other patches in-radius 4 with [pcolor = black or pcolor = brown]
[ let attack-severity (10 + one-of [20 50 70 90])
set dikunjungi-gajah? True
set frekuensi-lahan-diserang frekuensi-lahan-diserang + 1
set waktu-dikunjungi-gajah ticks
ask plants-here
[ ifelse [dipasangi-pagar-listrik?] of patch-here = True [set last-adjusted-attack-damage 0 serang-sebelahnya2
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage)] ]
[membantu-lahan-warga
let P count people-here
set reduced-damage efek-bantuan-orang * P
ifelse (attack-severity - reduced-damage) > 0 [set last-adjusted-attack-damage (attack-severity - reduced-damage)][set last-adjusted-attack-damage 0]
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage)]
]
]
]
]
end
to serang-sebelahnya2
if any? other patches in-radius 6 with [(pcolor = green or pcolor = 62) and kepemilikan != [kepemilikan] of myself and (any? other patches in-radius 1 with [pcolor = black or pcolor = brown])] [
ask one-of other patches in-radius 6 with [(pcolor = green or pcolor = 62) and kepemilikan != [kepemilikan] of myself and (any? other patches in-radius 1 with [pcolor = black or pcolor = brown])]
; if any? other patches in-radius 4 with [pcolor = black or pcolor = brown]
[ let attack-severity (10 + one-of [20 50 70 90])
set dikunjungi-gajah? True
set frekuensi-lahan-diserang frekuensi-lahan-diserang + 1
set waktu-dikunjungi-gajah ticks
ask plants-here
[ ifelse [dipasangi-pagar-listrik?] of patch-here = True [set last-adjusted-attack-damage 0
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage) ]
] ;muncul error recursion to deep
[membantu-lahan-warga
let P count people-here
set reduced-damage efek-bantuan-orang * P
ifelse (attack-severity - reduced-damage) > 0 [set last-adjusted-attack-damage (attack-severity - reduced-damage)][set last-adjusted-attack-damage 0]
if kondisi-tanaman > 10 [set kondisi-tanaman (kondisi-tanaman - last-adjusted-attack-damage)]
]
]
]
]
end
to gulung-tikar ;revisit
let a sawit-expenditure
let b padi-expenditure
let c karet-expenditure
ask people with [jumlah-lahan-produktif = 0 and saldo < (min (list a b c) + cash-reserve) or saldo <= 0][
; ask people with [people-nearby = myself][set people-nearby one-of other people]
ask plants with [ownership = myself][die]
ask patches with [kepemilikan = myself][set kepemilikan 0 ]
die
]
; ask people with [jumlah-lahan-produktif = 0] [
; ask people with [people-nearby = myself][set people-nearby one-of other people]
; if saldo > (sawit-expenditure + cash-reserve) [
; die]
;]
ask patches with [kepemilikan = 0][set pcolor black]
end
to individual-buy-fence2
ask people [
carefully
[set bayesian-beliefs individual-bayesian-updating2]
[set bayesian-beliefs 0]
]
ask people with [decision-individual-buy-fence = False or decision-individual-buy-fence = "ready to adopt" ][
set estimated-cost-pagar-listrik 18900000 + (cost-pagar-listrik * assess-perimeter)
ifelse kesadaran < treshold-kesadaran
[if pengetahuan > treshold-pengetahuan
[if saldo > estimated-cost-pagar-listrik + cash-reserve
[set decision-individual-buy-fence final-decision
]
]
]
[ if not any? patches with [kepemilikan = self and jenis-lahan = "illegal"]
[if pengetahuan > treshold-pengetahuan
[if saldo > estimated-cost-pagar-listrik + cash-reserve
[set decision-individual-buy-fence final-decision
]
]
]
]
if decision-individual-buy-fence = True
[
set saldo (saldo - estimated-cost-pagar-listrik)
set time-adopt ticks
ask patches with [kepemilikan = myself][ set dipasangi-pagar-listrik? True ]
]
]
; kalo kesadaran tinggi ditanyain :
;apakah lahan saya legal --> kalo ga legal pasang pagar listrik
end
;to pola-kolektivitas
;let m from-row-list: [[
; let [solidaritas] of people (random 100)
; set global-matrix (matrix:from-row-list n-values [list [kedekatan] of links])
;revisit --> cara bikin matrix nya menjadi dinamis berdasarkan frekuensi bertemu
;end
to skema-cicil
if cicilan-berlaku = True [
ask people with [decision-individual-buy-fence = "Kolektif"] [
set beban-premi (collective-fence-cost / (6 * count people with [decision-individual-buy-fence = "Kolektif"]) )
set lagi-nyicil True
if lagi-nyicil = True [
if beban-premi < saldo + cash-reserve
[set saldo saldo - beban-premi
set jumlah-premi-dibayar jumlah-premi-dibayar + 1
set saldo-kolektif saldo-kolektif + [beban-premi] of self
]
]
]
]
if saldo-kolektif >= collective-fence-cost
[ ask patches with [kepemilikan != 0 and jenis-lahan = "legal"][set dipasangi-pagar-listrik? True]
set saldo-kolektif saldo-kolektif - collective-fence-cost
set cicilan-berlaku False]
ask people [if jumlah-premi-dibayar >= 6
[set lagi-nyicil False
set time-adopt ticks] ]
end
to kolektif-buying-fence
set collective-fence-cost (sum [assess-perimeter] of people with [decision-individual-buy-fence != True] * harga-grosir + 18900000 * count people with [decision-individual-buy-fence != True])