-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGH-MC.nlogo
1386 lines (1238 loc) · 20.3 KB
/
GH-MC.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
globals [g-catsheets g-amc-deck g-freq-record g-reshuffle? g-cur-amcs
g-attack-values g-effect-freq]
turtles-own [category value rolling? special shuffle? cumulative?]
to reset
ca
set st_x0 1
set st_-2 1
set st_-1 5
set st_0 6
set st_+1 5
set st_+2 1
set st_x2 1
set curses 0
set blesses 0
set sp1-freq 0
set sp2-freq 0
set sp3-freq 0
set sp4-freq 0
set sp5-freq 0
set sp6-freq 0
set sp7-freq 0
set sp8-freq 0
set sp9-freq 0
set sp10-freq 0
end
to setup
ca
create-catsheets
foreach g-catsheets [ cur-catsheet ->
crt item 1 cur-catsheet [
set category item 0 cur-catsheet
set value item 2 cur-catsheet
set rolling? item 3 cur-catsheet
set special item 4 cur-catsheet
set shuffle? item 5 cur-catsheet
ifelse special > 0 [
set cumulative? item 6 cur-catsheet
][
set cumulative? false
]
]
]
set g-amc-deck shuffle sort turtles
let #categories [category] of max-one-of turtles [category]
set g-freq-record n-values #categories [0]
set g-cur-amcs []
set g-reshuffle? false
let #special-effects [special] of max-one-of turtles [special]
set g-effect-freq n-values #special-effects [0]
set g-attack-values []
reset-ticks
end
to create-catsheets
set g-catsheets (list standard_x0 standard_-2 standard_-1 standard_0 standard_+1 standard_+2 standard_x2 curse bless special1 special2 special3 special4 special5 special6 special7 special8 special9 special10)
end
to draw [repetitions]
repeat repetitions [
ifelse attack-mode = "normal" [
draw-core
][
repeat 2 [draw-core]
]
while [not member? false map [x -> [rolling?] of x] g-cur-amcs] [
draw-core
]
evaluate
if remove-bless-curse [
let to-remove-amcs turtles with [(category = 8 or category = 9) and not
member? self g-amc-deck]
ask to-remove-amcs [die]
]
if g-reshuffle? [
set g-amc-deck shuffle sort turtles
set g-reshuffle? false
]
]
tick
end
to draw-core
if empty? g-amc-deck [
set g-amc-deck shuffle sort turtles with [not member? category [8 9]
or not member? self g-cur-amcs]
set g-reshuffle? false
]
ask first g-amc-deck [
set g-cur-amcs lput self g-cur-amcs
set g-amc-deck but-first g-amc-deck
if shuffle? [
set g-reshuffle? true
]
; let mylistcat category - 1
; set g-freq-record replace-item mylistcat g-freq-record (item mylistcat g-freq-record + 1)
; if remove-bless-curse and (category = 8 or category = 9) [
; die
; ]
]
end
to evaluate
ifelse length g-cur-amcs = 2 and not member? true map [x -> [rolling?] of x]
g-cur-amcs [
let ts-cur-amcs (turtle-set g-cur-amcs)
let ambiguous? false
let better-amc 0
ifelse [special] of item 0 g-cur-amcs > 0 and
[special] of item 1 g-cur-amcs > 0 [
set g-cur-amcs but-last g-cur-amcs
set ambiguous? true
][
; any x0 amcs?
ifelse any? ts-cur-amcs with [member? category [1 8]] [
ask one-of ts-cur-amcs with [member? category [1 8]] [
set better-amc other ts-cur-amcs
]
][
let x2amc-to-reset no-turtles
let x2amc one-of ts-cur-amcs with [member? category [7 9]]
if x2amc != nobody [
ask x2amc [
set value base-damage * 2
set x2amc-to-reset self
]
]
let special-amc one-of ts-cur-amcs with [special > 0]
ifelse special-amc != nobody [
ask special-amc [
let other-amc other ts-cur-amcs
ifelse value >= first [value] of other-amc [
set better-amc self
set ambiguous? false
][
set g-cur-amcs but-last g-cur-amcs
set ambiguous? true
]
]
][
set better-amc max-one-of ts-cur-amcs [value]
set ambiguous? false
]
ask x2amc-to-reset [set value 0]
]
]
if not ambiguous? [
ask better-amc [
ifelse attack-mode = "advantage" [
set g-cur-amcs (list self)
][
set g-cur-amcs (list other ts-cur-amcs)
]
]
]
][
if attack-mode = "disadvantage" [
let ts-cur-amcs (turtle-set g-cur-amcs)
ask ts-cur-amcs with [not rolling?] [
; g-cur-amcs should be a single turtle! (todo: add check?)
set g-cur-amcs (list self)
]
]
]
let ts-cur-amcs (turtle-set g-cur-amcs)
; determine the attacks special effects
; empty agentsets create empty lists
let non-cum-amcs remove-duplicates [special] of ts-cur-amcs with [
special > 0 and not cumulative?]
let cum-amcs [special] of ts-cur-amcs with [cumulative?]
let amc-effects (sentence cum-amcs non-cum-amcs)
; apply the attacks special effects
foreach amc-effects [cur-effect ->
let cur-position cur-effect - 1
set g-effect-freq replace-item cur-position g-effect-freq
(item cur-position g-effect-freq + 1)
]
; apply the numerical modifiers
ifelse any? ts-cur-amcs with [member? category [1 8]] [
set g-attack-values lput 0 g-attack-values
][
let sum-positive-amcs sum [value] of ts-cur-amcs with [value > 0]
set sum-positive-amcs sum-positive-amcs + base-damage
if any? ts-cur-amcs with [member? category [7 9]] [
set sum-positive-amcs (sum-positive-amcs * 2)
]
let sum-negative-amcs sum [value] of ts-cur-amcs with [value < 0]
let sum-all-amcs sum-positive-amcs + sum-negative-amcs
set g-attack-values lput sum-all-amcs g-attack-values
]
set g-cur-amcs []
end
to-report standard_x0
; category, #of cards, value, rolling?, special?, shuffle?, cumulative?
report (list 1 st_x0 0 false 0 true false)
end
to-report standard_-2
report (list 2 st_-2 -2 false 0 false false)
end
to-report standard_-1
report (list 3 st_-1 -1 false 0 false false)
end
to-report standard_0
report (list 4 st_0 0 false 0 false false)
end
to-report standard_+1
report (list 5 st_+1 1 false 0 false false)
end
to-report standard_+2
report (list 6 st_+2 2 false 0 false false)
end
to-report standard_x2
report (list 7 st_x2 0 false 0 true false)
end
to-report curse
report (list 8 curses 0 false 0 false false)
end
to-report bless
report (list 9 blesses 0 false 0 false false)
end
; special attack modifiers
to-report special1
report (list 10 sp1-freq sp1-val sp1-roll sp1-special false sp1-cum)
end
to-report special2
report (list 11 sp2-freq sp2-val sp2-roll sp2-special false sp2-cum)
end
to-report special3
report (list 12 sp3-freq sp3-val sp3-roll sp3-special false sp3-cum)
end
to-report special4
report (list 13 sp4-freq sp4-val sp4-roll sp4-special false sp4-cum)
end
to-report special5
report (list 14 sp5-freq sp5-val sp5-roll sp5-special false sp5-cum)
end
to-report special6
report (list 15 sp6-freq sp6-val sp6-roll sp7-special false sp6-cum)
end
to-report special7
report (list 16 sp7-freq sp7-val sp7-roll sp7-special false sp7-cum)
end
to-report special8
report (list 17 sp8-freq sp8-val sp8-roll sp8-special false sp8-cum)
end
to-report special9
report (list 18 sp9-freq sp9-val sp9-roll sp9-special false sp9-cum)
end
to-report special10
report (list 19 sp10-freq sp10-val sp10-roll sp10-special false sp10-cum)
end
;setup draw 1000000 show mean g-attack-values let draws length g-attack-values let dist map [x -> (round ((x / draws) * 10000)) / 100] g-effect-freq print dist
@#$#@#$#@
GRAPHICS-WINDOW
210
10
257
58
-1
-1
13.0
1
10
1
1
1
0
1
1
1
-1
1
-1
1
0
0
1
ticks
30.0
SLIDER
22
117
194
150
base-damage
base-damage
1
10
2.0
1
1
NIL
HORIZONTAL
SWITCH
23
158
187
191
remove-bless-curse
remove-bless-curse
1
1
-1000
TEXTBOX
28
224
103
266
Standard Attack Modifiers
11
0.0
1
INPUTBOX
25
273
75
333
st_x0
1.0
1
0
Number
INPUTBOX
24
335
74
395
st_-2
1.0
1
0
Number
INPUTBOX
25
398
75
458
st_-1
5.0
1
0
Number
INPUTBOX
24
461
74
521
st_0
6.0
1
0
Number
INPUTBOX
23
523
73
583
st_+1
5.0
1
0
Number
INPUTBOX
22
585
72
645
st_+2
1.0
1
0
Number
INPUTBOX
23
648
73
708
st_x2
1.0
1
0
Number
INPUTBOX
22
725
72
785
curses
0.0
1
0
Number
INPUTBOX
22
787
72
847
blesses
0.0
1
0
Number
BUTTON
117
13
180
46
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
22
11
85
44
NIL
reset
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
TEXTBOX
294
25
444
43
Special Attack Modifiers
11
0.0
1
INPUTBOX
291
57
341
117
sp1-freq
0.0
1
0
Number
INPUTBOX
290
122
350
182
sp1-val
0.0
1
0
Number
SWITCH
289
187
392
220
sp1-roll
sp1-roll
1
1
-1000
CHOOSER
35
64
173
109
attack-mode
attack-mode
"advantage" "normal" "disadvantage"
1
INPUTBOX
470
55
520
115
sp2-freq
0.0
1
0
Number
INPUTBOX
468
121
518
181
sp2-val
0.0
1
0
Number
SWITCH
468
187
558
220
sp2-roll
sp2-roll
1
1
-1000
INPUTBOX
652
50
702
110
sp3-freq
0.0
1
0
Number
INPUTBOX
833
45
883
105
sp4-freq
0.0
1
0
Number
INPUTBOX
997
49
1047
109
sp5-freq
0.0
1
0
Number
INPUTBOX
296
407
346
467
sp6-freq
0.0
1
0
Number
INPUTBOX
469
407
519
467
sp7-freq
0.0
1
0
Number
INPUTBOX
664
407
714
467
sp8-freq
0.0
1
0
Number
INPUTBOX
842
406
892
466
sp9-freq
0.0
1
0
Number
INPUTBOX
1007
402
1064
462
sp10-freq
0.0
1
0
Number
INPUTBOX
652
113
702
173
sp3-val
0.0
1
0
Number
INPUTBOX
834
109
884
169
sp4-val
0.0
1
0
Number
INPUTBOX
998
111
1048
171
sp5-val
0.0
1
0
Number
INPUTBOX
296
470
346
530
sp6-val
0.0
1
0
Number
INPUTBOX
467
470
517
530
sp7-val
0.0
1
0
Number
INPUTBOX
664
470
714
530
sp8-val
0.0
1
0
Number
INPUTBOX
843
468
893
528
sp9-val
0.0
1
0
Number
INPUTBOX
1007
465
1062
526
sp10-val
0.0
1
0
Number
SWITCH
651
178
741
211
sp3-roll
sp3-roll
1
1
-1000
SWITCH
833
172
923
205
sp4-roll
sp4-roll
1
1
-1000
SWITCH
998
175
1088
208
sp5-roll
sp5-roll
1
1
-1000
SWITCH
294
532
384
565
sp6-roll
sp6-roll
1
1
-1000
SWITCH
466
531
556
564
sp7-roll
sp7-roll
1
1
-1000
SWITCH
663
533
753
566
sp8-roll
sp8-roll
1
1
-1000
SWITCH
843
529
933
562
sp9-roll
sp9-roll
1
1
-1000
SWITCH
1006
528
1096
561
sp10-roll
sp10-roll
1
1
-1000
INPUTBOX
290
223
355
283
sp1-special
0.0
1
0
Number
INPUTBOX
468
225
532
285
sp2-special
0.0
1
0
Number
INPUTBOX
1008
563
1082
623
sp10-special
0.0
1
0
Number
INPUTBOX
999
210
1067
270
sp5-special
0.0
1
0
Number
INPUTBOX
843
566
910
626
sp9-special
0.0
1
0
Number
INPUTBOX
836
208
903
268
sp4-special
0.0
1
0
Number
INPUTBOX
662
569
732
629
sp8-special
0.0
1
0
Number
INPUTBOX
467
566
535
626
sp7-special
0.0
1
0
Number
INPUTBOX
651
215
719
275
sp3-special
0.0
1
0
Number
INPUTBOX
294
566
360
626
sp6-special
0.0
1
0
Number
SWITCH
289
285
379
318
sp1-cum
sp1-cum
1
1
-1000
SWITCH
468
288
558
321
sp2-cum
sp2-cum
1
1
-1000
SWITCH
650
279
740
312
sp3-cum
sp3-cum
1
1
-1000
SWITCH
833
272
923
305
sp4-cum
sp4-cum
1
1
-1000
SWITCH
1002
274
1092
307
sp5-cum
sp5-cum
1
1