forked from JHaack4/CaveGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJudge.java
1539 lines (1391 loc) · 73.5 KB
/
Judge.java
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
import java.util.*;
import java.awt.image.BufferedImage;
import java.io.*;
public class Judge {
Stats stats;
Judge(Stats s) {
stats = s;
}
HashSet<String> plantNames = hashSet("ooinu_s,ooinu_l,wakame_s,wakame_l,kareooinu_s,kareooinu_l,daiodored,daiodogreen,clover,hikarikinoko,tanpopo,zenmai,nekojarashi,tukushi,magaret,watage,chiyogami");
HashSet<String> hazardNames = hashSet("gashiba,hiba,elechiba,rock");
HashSet<String> noCarcassNames = hashSet("wealthy,fart,kogane,mar,hanachirashi,damagumo,bigfoot,bigtreasure,qurione,baby,bomb,egg,kurage,onikurage,bombotakara,blackman,tyre,houdai,ooinu_s,ooinu_l,wakame_s,wakame_l,kareooinu_s,kareooinu_l,daiodored,daiodogreen,clover,hikarikinoko,tanpopo,zenmai,nekojarashi,tukushi,magaret,watage,chiyogami,gashiba,hiba,elechiba,rock,bluepom,redpom,yellowpom,blackpom,whitepom,randpom,pom");
HashSet<String> pomNames = hashSet("bluepom,redpom,yellowpom,blackpom,whitepom,randpom,pom");
HashSet<String> ignoreTreasuresPoD = hashSet("kinoko_doku,bird_hane,futa_a_silver,flower_red,flower_blue,g_futa_kyodo,dia_a_green,makigai,mojiban,nut,dashboots,cookie_m_l,bane_red,chocolate,tape_blue");
HashSet<String> optionalTreasuresPoD = hashSet("chess_queen_white,gum_tape_s,chess_king_white,chess_queen_black,leaf_normal,locket"); // bey_goma (SL), others on sh6, scx1, fc6, cos1, cos4
HashSet<String> purple20 = hashSet("EC-2,FC-1,HoB-2,CoS-2,GK-2,SR-2"), white20 = hashSet("WFG-3,BK-1,SH-2,SR-1");
/*
judge [pod at (default for story) key cmat score (default for challenge)]
<1% or >99% : only output top/bottom percentile of results (for images and prints) as compared to the distribution of 100K random seeds.
combine: combine results across seeds for the final sorted list output
pod: output is seconds - [expected pokos - collected pokos] / 2
at: output is seconds (penalties included for missing purple flowers and treasures)
cmat/cmal: output is seconds
attk (score attack): output is ( pokos * 10 + [start pikis+8*queen candypops] * 10 + start time - seconds / 2 ) (meant to guess the final score)
find good layouts is pretty good, just need to handle gates
defaults: pod/score
low score is better
special cases:
pod sh 6 - (todo?)
pod breadbugs/high treasures
*/
HashMap<String, Double> scoreMap = new HashMap<String, Double>();
HashMap<String, Double> rankMap = new HashMap<String, Double>();
HashMap<String, Double> seedAggregatedScoreMap = new HashMap<String, Double>();
HashSet<String> seeds = new HashSet<String>();
double judgeVsAvgCumScores[] = new double[100000], judgeVsAvgCumScore = 0;
void judge(CaveGen g) {
// calculate score... (in this function, "score" is based on jhawk's heuristics, not the game's version of score)
double score = 0;
ArrayList<Teki> placedTekisWithItemsInside;
placedTekisWithItemsInside = new ArrayList<Teki>();
for (Teki t: g.placedTekis) {
if (t.itemInside != null) {
placedTekisWithItemsInside.add(t);
}
}
if (CaveGen.judgeType.equals("score")) { // sum of scores, using the game's version of score
int treasureCount = 0;
for (Item t: g.placedItems) {
score += t.spawnPoint.mapUnit.unitScore;
treasureCount += 1;
}
for (Teki t: placedTekisWithItemsInside) {
if (t.spawnPoint.type == 5)
score += t.spawnPoint.door.doorScore;
else
score += t.spawnPoint.mapUnit.unitScore;
treasureCount += 1;
}
score += 100000 * (expectedNumTreasures - treasureCount); // add penalty for missing treasures
}
else if (CaveGen.judgeType.equals("pod")) {
HashSet<SpawnPoint> visited = new HashSet<SpawnPoint>();
HashSet<SpawnPoint> unVisited = new HashSet<SpawnPoint>();
visited.add(g.placedStart);
int numPokosCollected = 0;
int numTreasuresCollected = 0;
for (Item t: g.placedItems) {
String name = t.itemName.toLowerCase();
if (!ignoreTreasuresPoD.contains(name) && !optionalTreasuresPoD.contains(name)) {
numTreasuresCollected += 1;
numPokosCollected += Parser.pokos.get(name);
unVisited.add(t.spawnPoint);
}
}
for (Teki t: placedTekisWithItemsInside) {
String name = t.itemInside;
if (!ignoreTreasuresPoD.contains(name) && !optionalTreasuresPoD.contains(name)) {
numTreasuresCollected += 1;
numPokosCollected += Parser.pokos.get(name);
unVisited.add(t.spawnPoint);
}
}
// compute pikmin*seconds required to collect all treasures
float pikminSeconds = 0;
float activePikmin = 0;
for (Item t: g.placedItems) {
String name = t.itemName.toLowerCase();
if (ignoreTreasuresPoD.contains(name) || optionalTreasuresPoD.contains(name)) continue;
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
float dig = 0;
if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
}
g.closestWayPoint(t.spawnPoint).hasCarryableBehind = true;
activePikmin += maxCarry;
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
}
for (Teki t: placedTekisWithItemsInside) {
String name = t.itemInside.toLowerCase();
if (ignoreTreasuresPoD.contains(name) || optionalTreasuresPoD.contains(name)) continue;
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
float dig = 0;
//if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
// dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
//}
g.closestWayPoint(t.spawnPoint).hasCarryableBehind = true;
activePikmin += maxCarry;
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
}
float carrySeconds = pikminSeconds == 0 ? 0 : pikminSeconds / Math.min(pikiCount, activePikmin);
// compute the minimum spanning tree, and add the time needed for the captain to walk it
float walkingSeconds = 0;
while (unVisited.size() > 0) {
float minDist = CaveGen.INF;
SpawnPoint minU = null;
for (SpawnPoint v: visited) {
for (SpawnPoint u: unVisited) {
float dist = v == g.placedStart ? g.spawnPointDistToStart(u) : g.spawnPointDist(v, u);
if (dist < minDist) {
minU = u;
minDist = dist;
}
}
}
walkingSeconds += (minDist / olimarSpeedCm);
unVisited.remove(minU);
visited.add(minU);
}
// walking to hole
if (g.placedHole != null) {
walkingSeconds += g.spawnPointDistToStart(g.placedHole) / olimarSpeedCm / (1 + numTreasuresCollected);
} else if (g.placedGeyser != null) {
walkingSeconds += g.spawnPointDistToStart(g.placedGeyser) / olimarSpeedCm / (1 + numTreasuresCollected);
} else {
walkingSeconds += 300; // ho holes
}
// Teki/Hazards that are in the way of treasures, bug pokos
float hazardSeconds = 0;
int bugPokos = 0;
computeWaypointCarryableGraph(g, ""); // pod treasures (already marked above)
for (Teki t: g.placedTekis) {
if (isInTheWay(g, t)) {
String name = t.tekiName.toLowerCase();
hazardSeconds += Parser.tekiDifficultyJudgeSec.get(name) / 2.0f;
if (!noCarcassNames.contains(name) && g.spawnPointDistToStart(t.spawnPoint) / olimarSpeedCm < walkingSeconds * 0.4f) {
bugPokos += Parser.pokos.get(name);
}
}
}
// collecting optional treasures (note, small flaw, these don't check for enemies in the way.)
float optionalTreasuresSeconds = 0;
for (Item t: g.placedItems) {
String name = t.itemName.toLowerCase();
if (!optionalTreasuresPoD.contains(name)) continue;
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
float dig = 0;
if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
}
float minDistToAlreadyVisitedWp = 128000;
for (MapUnit m: g.placedMapUnits) {
for (WayPoint wp: m.wayPoints) {
if (!wp.hasCarryableBehind && !wp.isStart) continue;
minDistToAlreadyVisitedWp = Math.min(minDistToAlreadyVisitedWp, g.spawnPointWayPointDist(t.spawnPoint, wp));
}
}
float gateCheck = 0;
if (g.placedGates.size() > 0) {
if (t.spawnPoint.mapUnit != null && t.spawnPoint.mapUnit.type == 0) { // only checking if in an alcove.
for (Gate gt: g.placedGates) {
if (gt.posX == t.spawnPoint.mapUnit.doors.get(0).posX && gt.posZ == t.spawnPoint.mapUnit.doors.get(0).posZ) {
gateCheck += Math.max(6, 3 + gt.life * gateLifeMultiplier / (pikiAttackValue * pikiCount));
}
}
}
}
float pikiCarryValueUse = g.specialCaveInfoName.equals("FC") && g.sublevel == 6 ? 2.4f : pikiCarryValue; // FC6 water override
float timeNeeded = 10 // cutscene
+ 2 * minDistToAlreadyVisitedWp / olimarSpeedCm // additional walking, use 2x since you also need to walk back
+ loadTimeSecondsStory + dig / (pikiCount / (numTreasuresCollected+1)) + gateCheck // load+dig+gate
+ g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValueUse * carry - minCarry + 1) / maxCarry);
//System.out.println("fgt" + 0 + " wlk" + (2*minDistToAlreadyVisitedWp / olimarSpeedCm) + " load" + loadTimeSecondsStory
// + " dig" + (dig / (pikiCount / (numTreasuresCollected+1))) + " carry" + (g.spawnPointDistToStart(t.spawnPoint)
// * carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry)) + " gate"+gateCheck);
int pokos = Parser.pokos.get(name);
float timeSave = Math.min(pokos / 4, pokos / 1.5f - timeNeeded); // 1.5 extra pokos = 1s (more than bugs due to optionality)
//System.out.println("opt " + name + " " + timeSave);
if (timeSave > 0) {
//System.out.println("collect");
optionalTreasuresSeconds -= timeSave;
}
}
for (Teki t: placedTekisWithItemsInside) {
String name = t.itemInside.toLowerCase();
if (!optionalTreasuresPoD.contains(name)) continue;
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
float dig = 0;
//if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
// dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
//}
float minDistToAlreadyVisitedWp = 128000;
for (MapUnit m: g.placedMapUnits) {
for (WayPoint wp: m.wayPoints) {
if (!wp.hasCarryableBehind) continue;
minDistToAlreadyVisitedWp = Math.min(minDistToAlreadyVisitedWp, g.spawnPointWayPointDist(t.spawnPoint, wp));
}
}
float timeNeeded = 10 // cutscene
+ Parser.tekiDifficultyJudgeSec.get(t.tekiName.toLowerCase()) // enemy fight
+ 2 * minDistToAlreadyVisitedWp / olimarSpeedCm // additional walking, use 2x since you also need to walk back
+ loadTimeSecondsStory + dig / (pikiCount / (numTreasuresCollected+1)) // load+dig
+ g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
//System.out.println("fgt" + Parser.tekiDifficultyJudgeSec.get(t.tekiName.toLowerCase()) + " wlk" + (2*minDistToAlreadyVisitedWp / olimarSpeedCm) + " load" + loadTimeSecondsStory
// + " dig" + (dig / (pikiCount / (numTreasuresCollected+1))) + " carry" + (g.spawnPointDistToStart(t.spawnPoint)
// * carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry)));
int pokos = Parser.pokos.get(name);
float timeSave = Math.min(pokos / 4, pokos / 1.5f - timeNeeded); // 1.5 extra pokos = 1s (more than bugs due to optionality)
//System.out.println("opt " + name + " " + timeSave);
if (timeSave > 0) {
//System.out.println("collect");
optionalTreasuresSeconds -= timeSave;
}
continue;
}
// gates that are in the way of holes/treasures
float gateSeconds = 0;
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "h"); // holes (+ pod treasures)
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
gateSeconds += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * pikiCount));
}
}
}
float pokoSeconds = expectedNumPokosPoD - numPokosCollected - bugPokos;
pokoSeconds /= 2.0f; // 2 bug pokos = 1s
// adjustments
float adjSeconds = 0;
if (CaveGen.specialCaveInfoName.equals("GK")) {
// gk2 shortcuts
if (CaveGen.sublevel == 2) {
for (Item i: g.placedItems) {
if (i.itemName.equalsIgnoreCase("g_futa_kyusyu")) {
if (i.spawnPoint.spawnListIdx == 6 || i.spawnPoint.spawnListIdx == 7)
walkingSeconds = 4.0f;
}
}
hazardSeconds = 0;
}
// high treasures
for (Item t: g.placedItems) {
if (ignoreTreasuresPoD.contains(t.itemName.toLowerCase())) continue;
if (t.spawnPoint.y == 100 || t.spawnPoint.y == 125) {
adjSeconds += 12;
//System.out.println("high treasure");
}
}
// breadbugs
for (Item i: g.placedItems) {
String name = i.itemName.toLowerCase();
if (ignoreTreasuresPoD.contains(name)) continue;
if (i.spawnPoint.y >= 30) continue; // high
if (Parser.minCarry.get(name) > 10) continue; // too heavy
if (g.spawnPointDistToStart(i.spawnPoint) < 170) continue; // too close
float worst = 0;
for (Teki t: g.placedTekis) {
if (t.tekiName.equalsIgnoreCase("panmodoki")) {
float closeness = g.spawnPointDist(t.spawnPoint, i.spawnPoint) / g.spawnPointDistToStart(i.spawnPoint);
if (closeness < 0.25) {
worst = Math.max(worst, Math.min(15, 1.5f / closeness));
}
}
}
adjSeconds += worst;
//if (worst > 0) System.out.println("breadbug " + worst + " " + name);
}
}
//System.out.println("carry" + carrySeconds + " walk" + walkingSeconds + " haz" + hazardSeconds + " gate" + gateSeconds);
//System.out.println("poko" + pokoSeconds + " adj" + adjSeconds + " opt" + optionalTreasuresSeconds);
score = walkingSeconds + carrySeconds + hazardSeconds + gateSeconds + optionalTreasuresSeconds
+ pokoSeconds + adjSeconds + 10*numTreasuresCollected;
}
else if (CaveGen.judgeType.equals("at")) {
int treasureCount = g.placedItems.size() + placedTekisWithItemsInside.size();
int numPurpleCandypop = 0;
for (Teki t: g.placedTekis)
if (t.tekiName.equalsIgnoreCase("blackpom"))
numPurpleCandypop += 1;
// compute the minimum spanning tree, and add the time needed for the captain to walk it
float walkingSeconds = 0;
HashSet<SpawnPoint> visited = new HashSet<SpawnPoint>();
HashSet<SpawnPoint> unVisited = new HashSet<SpawnPoint>();
visited.add(g.placedStart);
for (Item t: g.placedItems) unVisited.add(t.spawnPoint);
for (Teki t: placedTekisWithItemsInside) unVisited.add(t.spawnPoint);
while (unVisited.size() > 0) {
float minDist = CaveGen.INF;
SpawnPoint minU = null;
for (SpawnPoint v: visited) {
for (SpawnPoint u: unVisited) {
float dist = v == g.placedStart ? g.spawnPointDistToStart(u) : g.spawnPointDist(v, u);
if (dist < minDist) {
minU = u;
minDist = dist;
}
}
}
walkingSeconds += (minDist / olimarSpeedCm);
unVisited.remove(minU);
visited.add(minU);
}
// walking to hole
if (g.placedHole != null) {
walkingSeconds += g.spawnPointDistToStart(g.placedHole) / olimarSpeedCm / (1 + expectedNumTreasures);
} else if (g.placedGeyser != null) {
walkingSeconds += g.spawnPointDistToStart(g.placedGeyser) / olimarSpeedCm / (1 + expectedNumTreasures);
} else {
walkingSeconds += 300; // ho holes
}
// purple candypops
if (!purple20.contains(sublevelId) && expectedNumPurpleCandypop > 0) {
for (Teki t: g.placedTekis) {
if (t.tekiName.equalsIgnoreCase("blackpom")) {
walkingSeconds += g.spawnPointDistToStart(t.spawnPoint) / olimarSpeedCm / (2 + expectedNumTreasures);
}
}
}
// compute pikmin*seconds required to collect all treasures
float pikminSeconds = 0;
float activePikmin = 0;
for (Item t: g.placedItems) {
String name = t.itemName.toLowerCase();
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
activePikmin += maxCarry;
float dig = 0;
if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
}
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
}
for (Teki t: placedTekisWithItemsInside) {
String name = t.itemInside.toLowerCase();
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
activePikmin += maxCarry;
float dig = 0;
//if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
// dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
//}
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
}
float carrySeconds = pikminSeconds == 0 ? 0 : pikminSeconds / Math.min(pikiCount, activePikmin);
// Teki/Hazards that are in the way of treasures
float hazardSeconds = 0;
computeWaypointCarryableGraph(g, "t"); // treasures
for (Teki t: g.placedTekis) {
if (isInTheWay(g, t)) {
String name = t.tekiName.toLowerCase();
hazardSeconds += Parser.tekiDifficultyJudgeSec.get(name) / 2.0f;
}
}
// gates that are in the way of holes/treasures
float gateSeconds = 0;
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "htp"); // holes + treasures + purple candypops
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
gateSeconds += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * pikiCount));
}
}
}
// penalties
float purpPenalty = purple20.contains(sublevelId) ? 0 : (60 * (expectedNumPurpleCandypop - numPurpleCandypop));
float treasurePenalty = treasureCount < expectedNumTreasures ? 300 : 0;
//System.out.println("carry" + carrySeconds + " walk" + walkingSeconds + " haz" + hazardSeconds + " gate" + gateSeconds);
//System.out.println("tpen" + treasurePenalty + " ppen" + purpPenalty);
score = walkingSeconds + carrySeconds + hazardSeconds + gateSeconds
+ treasurePenalty + purpPenalty + 10*treasureCount;
}
else if (CaveGen.judgeType.equals("attk")) {
// compute the number of pokos availible on this layout
int pokosAvailible = 0;
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (name.equalsIgnoreCase("egg"))
pokosAvailible += 10; // mitites
else if (!noCarcassNames.contains(name))
pokosAvailible += Parser.pokos.get(name);
if (t.itemInside != null)
pokosAvailible += Parser.pokos.get(t.itemInside.toLowerCase());
}
for (Item t: g.placedItems)
pokosAvailible += Parser.pokos.get(t.itemName.toLowerCase());
// compute the number of pikmin*seconds required to complete the level
float pikminSeconds = 0;
int numHazards = 0;
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (plantNames.contains(name)) continue;
if (hazardNames.contains(name)) {
numHazards += 1;
continue;
}
pikminSeconds += Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name);
pikminSeconds += judgeWorkFunction(g, t.tekiName, t.spawnPoint);
//System.out.println(name + " " + (Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name)) + " " + judgeWorkFunction(g, t.tekiName, t.spawnPoint));
if (t.itemInside != null)
pikminSeconds += judgeWorkFunction(g, t.itemInside, t.spawnPoint);
//if (t.itemInside != null) System.out.println("-" + t.itemInside + " " + judgeWorkFunction(g, t.itemInside, t.spawnPoint));
}
for (Item t: g.placedItems) {
pikminSeconds += judgeWorkFunction(g, t.itemName, t.spawnPoint);
//System.out.println(t.itemName + " " + judgeWorkFunction(g, t.itemName, t.spawnPoint));
}
pikminSeconds += judgeWorkFunction(g, "hole", g.placedHole);
//System.out.println("hole " + judgeWorkFunction(g, "hole", g.placedHole));
pikminSeconds += judgeWorkFunction(g, "geyser", g.placedGeyser);
//System.out.println("geyser " + judgeWorkFunction(g, "geyser", g.placedGeyser));
// Hazards that are in the way of treasures/carcasses
if (numHazards > 0) {
computeWaypointCarryableGraph(g, "tc"); // treasures + carcasses
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (hazardNames.contains(name) && isInTheWay(g, t)) {
pikminSeconds += Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name);
//System.out.println(t.tekiName + " " + (Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name)));
}
}
}
// gates that are in the way of holes/treasures/carcasses
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "htc"); // holes + treasures + carcasses
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
float wallCount = pikiCount / 2.0f;
pikminSeconds += wallCount * Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount));
//System.out.println("gate " + (wallCount * Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount))));
}
}
}
// geyser breaking
if (g.placedGeyser != null && g.holeClogged) {
pikminSeconds += geyserHealth / pikiAttackValue;
//System.out.println("clog " + geyserHealth / pikiAttackValue);
}
//System.out.println("cnt " + pikiCount + " attk " + pikiAttackValue + " crry " + pikiCarryValue + " strg " + pikiStrengthValue + " poko " + pokosAvailible + " time " + Parser.chTime.get(sublevelId) );
float pikminEfficiencyRate = 1.0f;
score = -pokosAvailible * 10 - pikiCount * 10 + Parser.chTime.get(sublevelId)
+ 0.5 * pikminSeconds / (pikiCount * pikminEfficiencyRate);
}
else if (CaveGen.judgeType.equals("cmat")) {
// compute the number of pikmin*seconds required to complete the level
float pikminSeconds = 0;
int numHazards = 0;
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (hazardNames.contains(name)) {
numHazards += 1;
continue;
}
if (t.itemInside == null) continue;
pikminSeconds += Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name);
//System.out.println(name + " " + (Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name)));
pikminSeconds += judgeWorkFunction(g, t.itemInside, t.spawnPoint);
//System.out.println("-" + t.itemInside + " " + judgeWorkFunction(g, t.itemInside, t.spawnPoint));
}
for (Item t: g.placedItems) {
pikminSeconds += judgeWorkFunction(g, t.itemName, t.spawnPoint);
//System.out.println(t.itemName + " " + judgeWorkFunction(g, t.itemName, t.spawnPoint));
}
pikminSeconds += judgeWorkFunction(g, "hole", g.placedHole);
//System.out.println("hole " + judgeWorkFunction(g, "hole", g.placedHole));
pikminSeconds += judgeWorkFunction(g, "geyser", g.placedGeyser);
//System.out.println("geyser " + judgeWorkFunction(g, "geyser", g.placedGeyser));
// Hazards that are in the way of treasures
if (numHazards > 0) {
computeWaypointCarryableGraph(g, "t"); // treasures
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (hazardNames.contains(name) && isInTheWay(g, t)) {
pikminSeconds += Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name);
//System.out.println(t.tekiName + " " + (Parser.tekiDifficultyJudgePiki.get(name) * Parser.tekiDifficultyJudgeSec.get(name)));
}
}
}
// gates that are in the way of holes/treasures
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "ht"); // holes + treasures
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
float wallCount = pikiCount / 2.0f;
pikminSeconds += wallCount * Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount));
//System.out.println("gate " + (wallCount * Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount))));
}
}
}
// geyser breaking
if (g.placedGeyser != null && g.holeClogged) {
pikminSeconds += geyserHealth / pikiAttackValue;
//System.out.println("clog " + geyserHealth / pikiAttackValue);
}
//System.out.println("cnt " + pikiCount + " attk " + pikiAttackValue + " crry " + pikiCarryValue + " strg " + pikiStrengthValue + " time " + Parser.chTime.get(sublevelId) );
float pikminEfficiencyRate = 1.0f;
score = pikminSeconds / (pikiCount * pikminEfficiencyRate);
boolean keyFound = false;
for (Item t: g.placedItems) {
if (t.itemName.equals("key")) {
keyFound = true;
break;
}
}
for (Teki t: g.placedTekis) {
if (keyFound) break;
if (t.itemInside != null && t.itemInside.equals("key")) {
keyFound = true;
break;
}
}
if (!keyFound) {
score = 500;
}
}
else if (CaveGen.judgeType.equals("key")) {
// travel time to key (including gates)
// + max (time to travel from key to hole, time for key to return to ship fastest carry)
// + time to break geyser
float tripKeyGates = 0;
float tripHoleGates = 0;
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "k"); // holes + treasures
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
float wallCount = pikiCount;
tripKeyGates += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount));
}
}
computeWaypointCarryableGraph(g, "h"); // holes + treasures
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
float wallCount = pikiCount;
tripHoleGates += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount));
}
}
tripHoleGates -= tripKeyGates;
}
float keyWalk = 0;
float keyCarry = 0;
float holeWalk = 0;
boolean keyFound = false;
for (Item t: g.placedItems) {
if (t.itemName.equals("key")) {
int carry = Math.min(pikiCount, 3);
keyWalk = g.spawnPointDistToStart(t.spawnPoint) / olimarSpeedCm;
keyCarry = g.spawnPointDistToStart(t.spawnPoint)
* carryMultiplier / (220.0f + 180.0f * (fastestPikiCarryValue * carry - 1 + 1) / 3);
if (g.placedHole != null)
holeWalk = g.spawnPointDist(g.placedHole, t.spawnPoint) / olimarSpeedCm;
if (g.placedGeyser != null)
holeWalk = g.spawnPointDist(g.placedGeyser, t.spawnPoint) / olimarSpeedCm;
holeWalk = Math.min(holeWalk, g.spawnPointDist(g.placedStart, t.spawnPoint) / olimarSpeedCm);
keyFound = true;
break;
}
}
for (Teki t: g.placedTekis) {
if (keyFound) break;
if (t.itemInside != null && t.itemInside.equals("key")) {
int carry = Math.min(pikiCount, 3);
keyWalk = g.spawnPointDistToStart(t.spawnPoint) / olimarSpeedCm
+ Parser.tekiDifficultyJudgeSec.get(t.tekiName.toLowerCase());
keyCarry = g.spawnPointDistToStart(t.spawnPoint)
* carryMultiplier / (220.0f + 180.0f * (fastestPikiCarryValue * carry - 1 + 1) / 3);
if (g.placedHole != null)
holeWalk = g.spawnPointDist(g.placedHole, t.spawnPoint) / olimarSpeedCm;
if (g.placedGeyser != null)
holeWalk = g.spawnPointDist(g.placedGeyser, t.spawnPoint) / olimarSpeedCm;
holeWalk = Math.min(holeWalk, g.spawnPointDist(g.placedStart, t.spawnPoint) / olimarSpeedCm);
keyFound = true;
break;
}
}
if (!keyFound) {
keyWalk = 300;
}
/*if (CaveGen.specialCaveInfoName.equals("CH16")) {
for (Teki t: g.placedTekis) {
if (t.itemInside != null && t.itemInside.equals("key")) {
for (Item i: g.placedItems) {
double dist = g.spawnPointDist(t.spawnPoint, i.spawnPoint);
if (dist < 70) {
keyWalk += dist < 40 ? 10 : 6;
}
}
}
}
}*/
// special cases: ch6 candypop, ch26 candypop, ch16 bbgs
float geyserBreak = 0;
if (g.placedGeyser != null)
geyserBreak = geyserHealth / pikiAttackValue / pikiCount;
//System.out.println("keywalk" + keyWalk + " keygates" + tripKeyGates + " keyCarry" + keyCarry + "holewalk" + holeWalk + " holegates" + tripHoleGates + " geyserbreak" + geyserBreak + " fastestcarry" + fastestPikiCarryValue);
score = (keyWalk + tripKeyGates)
+ Math.max(keyCarry, holeWalk + tripHoleGates)
+ geyserBreak;
}
else if (CaveGen.judgeType.equals("colossal")) { // this could definetly be improved someday.
// travel time to globe (including gates)
// + time for globe to return to ship fastest carry
float tripKeyGates = 0;
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "m"); // globe
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
float wallCount = pikiCount;
tripKeyGates += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * wallCount));
}
}
}
float keyWalk = 0;
float keyCarry = 0;
boolean keyFound = false;
for (Teki t: g.placedTekis) {
if (t.itemInside != null && t.itemInside.equals("map01")) {
int carry = Math.min(pikiCount, 3);
keyWalk = g.spawnPointDistToStart(t.spawnPoint) / olimarSpeedCm
+ Parser.tekiDifficultyJudgeSec.get(t.tekiName.toLowerCase());
keyCarry = g.spawnPointDistToStart(t.spawnPoint)
* carryMultiplier / (220.0f + 180.0f * (fastestPikiCarryValue * carry - 40 + 1) / 100);
keyFound = true;
break;
}
}
if (!keyFound) {
keyWalk = 100000;
}
int treasureCount = g.placedItems.size() + placedTekisWithItemsInside.size();
// compute pikmin*seconds required to collect all treasures
float pikminSeconds = 0;
float activePikmin = 0;
for (Onion o: g.placedOnions) {
pikminSeconds +=
10 * pikiCount * g.spawnPointDistToStart(o.spawnPoint) / 170.0f;
}
for (Item t: g.placedItems) {
String name = t.itemName.toLowerCase();
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
activePikmin += maxCarry;
float dig = 0;
if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
}
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry) / 1.3f;
}
for (Teki t: placedTekisWithItemsInside) {
String name = t.itemInside.toLowerCase();
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = maxCarry;
activePikmin += maxCarry;
float dig = 0;
//if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
// dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
//}
pikminSeconds +=
carry * loadTimeSecondsStory + dig + // loading + digging
carry * g.spawnPointDistToStart(t.spawnPoint) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry) / 1.3f;
}
float carrySeconds = pikminSeconds == 0 ? 0 : pikminSeconds / Math.min(pikiCount, activePikmin);
// Teki/Hazards that are in the way of treasures
float hazardSeconds = 0;
computeWaypointCarryableGraph(g, "t"); // treasures
for (Teki t: g.placedTekis) {
String name = t.tekiName.toLowerCase();
if (isInTheWay(g, t)) {
hazardSeconds += Parser.tekiDifficultyJudgeSec.get(name) / 2.0f;
}
}
// gates that are in the way of holes/treasures
float gateSeconds = 0;
if (g.placedGates.size() > 0) {
computeWaypointCarryableGraph(g, "htp"); // holes + treasures + purple candypops
for (Gate t: g.placedGates) {
if (isInTheWay(g, t)) {
gateSeconds += Math.max(6, 3 + t.life * gateLifeMultiplier / (pikiAttackValue * pikiCount));
}
}
}
float treasurePenalty = treasureCount < expectedNumTreasures ? 10000 * (expectedNumTreasures - treasureCount): 0;
//System.out.println("carry" + carrySeconds + " walk" + walkingSeconds + " haz" + hazardSeconds + " gate" + gateSeconds);
//System.out.println("tpen" + treasurePenalty + " ppen" + purpPenalty);
//System.out.println("kWalk" + keyWalk + " kCarry" + keyCarry);
//stats.println("kWalk" + keyWalk + " kCarry" + keyCarry);
score = tripKeyGates + keyWalk + keyCarry
+ carrySeconds + hazardSeconds + gateSeconds
+ treasurePenalty;
}
else if (CaveGen.judgeType.equals("mapunitcount")) {
score = g.placedMapUnits.size();
}
// calculate rank
double rank = scoreToRank(score);
// add to dictionaries
String seedStr = Drawer.seedToString(g.initialSeed);
String s = CaveGen.specialCaveInfoName + "-" + CaveGen.sublevel + " " + seedStr;
scoreMap.put(s, score);
rankMap.put(s, rank);
if (seeds.contains(seedStr)) {
seedAggregatedScoreMap.put(seedStr, seedAggregatedScoreMap.get(seedStr) + score);
} else {
seeds.add(seedStr);
seedAggregatedScoreMap.put(seedStr, score);
}
if (CaveGen.judgeVsAvg) {
judgeVsAvgCumScore += score;
}
// check if the image passes the filter
if (filter(score, rank)) {
if (CaveGen.numToGenerate < 4096 || CaveGen.judgeFilterRank != 0 || CaveGen.judgeFilterScore != 0) {
stats.println(String.format("Judge: %s -> %.2f (%.1f%%, %s)", s, score, rank, rankBreakPoints==null?"?":""+(int)(score-rankBreakPoints[500])));
if (CaveGen.prints)
System.out.println(String.format("Judge: %s -> %.2f (%.1f%%, %s)", s, score, rank,rankBreakPoints==null?"?":""+(int)(score-rankBreakPoints[500])));
}
CaveGen.imageToggle = true;
}
else {
CaveGen.imageToggle = false;
}
}
// units of return type is pikmin*seconds
// used for score attack and cmat heuristics
float judgeWorkFunction(CaveGen g, String name, SpawnPoint sp) {
if (sp == null) return 0;
name = name.toLowerCase();
if (name.equals("hole"))
return g.spawnPointDistToStart(sp) / olimarSpeedCm * holeWorkMultiplier; // walking cost
if (name.equals("geyser"))
return g.spawnPointDistToStart(sp) / olimarSpeedCm * geyserWorkMultiplier; // walking cost
if (name.equals("egg")) // assume 10 mitites
return 10 * g.spawnPointDistToStart(sp) / olimarSpeedCm + 10 * loadTimeSeconds + // walking/loading cost
10 * g.spawnPointDistToStart(sp) * carryMultiplier / (220.0f + 180.0f * (pikiCarryValue)); // carry cost
if (pomNames.contains(name))
return g.spawnPointDistToStart(sp) / olimarSpeedCm * candypopWorkMultiplier; // walking cost
if (noCarcassNames.contains(name)) return 0;
int minCarry = Parser.minCarry.get(name);
int maxCarry = Parser.maxCarry.get(name);
int carry = (int)Math.ceil(minCarry / pikiStrengthValue);
float dig = 0;
if (Parser.depth.containsKey(name) && Parser.depth.get(name) > 0) {
dig = Math.min(1, Parser.depth.get(name)/Parser.height.get(name)) * diggingHealth / pikiDigValue;
}
return carry * loadTimeSeconds + dig + // loading + digging
carry * g.spawnPointDistToStart(sp) / olimarSpeedCm + // walking cost
carry * g.spawnPointDistToStart(sp) // carry cost
* carryMultiplier / (220.0f + 180.0f * (pikiCarryValue * carry - minCarry + 1) / maxCarry);
}
// CARRY NOTES
// carry velocity (wiki) is 220 + 180 * (sum_i piki_i - minCarry + 1) / maxCarry
// piki_i = (purp: 0.6, white: 3.0, rest: 1.0) + (leaf: 0.0, bud: 0.5, flower: 1.0)
// my unit adjustment: carry velocity is (220 + 180 * (sum_i piki_i - minCarry + 1) / maxCarry) / 8.5 cm/s
// olimar moves 1.17 units/s = 199.8 cm/s without rush boots.
// rush boots 4 units / 3.68s, without 4 units / 4.70s (ratio is 205/160)
final float olimarSpeedUnitsNoRush = 1.17f;
final float olimarSpeedUnitsRush = 1.17f * 205 / 160;
// cm = in game units of x/z measurement (waypoint distances are in cm)
// unit = length of 1 map unit
// 170cm = 1 unit.
// carrying formula on wiki gives measurements in some arbitrary velocity unit.
// however, if you divide by ~8.5, the carrying formula is in cm/s.
// trials on HoB 1: 8.53,8.44,8.63,8.54,8.40,8.32
// 1 flower on grub 5 units / 12.51s (sumpiki = 2, vel = 220+180*2=580)
// 1 leaf on grub 5 units / 17.94s (sumpiki = 1, vel = 220+180*1=400)
// 1 purp flower 5 units / 14.45s (sumpiki = 1.6, vel = 220+180*1.6=508)
final float carryMultiplier = 8.5f;
// gate notes:
// formula: time in seconds = max(6, 3 + life * 2 / attkpower)
// ~6s of fixed costs
// 1 life (ch12) 6s
// 4000 life 18*60, 9s, 16s, 27*18
// 2500 life 100 attk 52s,, 50 attk 102s, 30 attk 170s, 20 attk 253
// (piki attack animation is 30 / 20s, 30/11s spicy)
final float gateLifeMultiplier = 2.0f;
// geyser health: 17s / 145 attk, 15s / 180 attk, 9s / 340 attk -> 2700
final float geyserHealth = 2700.0f;
// digging:
// iid says: HP is 3900 and Pikmin digs once per a second
// First 480HP requires whites
// Theoretical digging time is 48/Pw + 342/P[s], where Pw is number of whites and P is weighted sum of Pikmin (Purple and Spicy:2, Red:1.5, others:1)
// my tests: 10 whites on ring/SAT: ~40s each. 5 whites: 78s.
// formula ~3900 / pikiDigSum
final float diggingHealth = 3900.0f;
// loading carryable objects (just made this up)
final float loadTimeSeconds = 0.5f;
final float loadTimeSecondsStory = 3.0f;
// these are computed once per sublevel based on what the game is trying to spawn.
int expectedNumTreasures;
int expectedNumQueenCandypop;
int previousNumQueenCandypop;
int expectedNumPurpleCandypop;
int expectedNumWhiteCandypop;
int expectedNumPokosPoD;
int expectedMaxCarry;
int pikiCount;
float holeWorkMultiplier, geyserWorkMultiplier, candypopWorkMultiplier;
float pikiCarryValue, pikiAttackValue, pikiStrengthValue, pikiDigValue, fastestPikiCarryValue;
String sublevelId;
boolean rushBoots;
float olimarSpeedCm;
void setupJudge(CaveGen g) {
readRankFile();
if (CaveGen.judgeVsAvg && rankBreakPoints != null) {
for (int i = 0; i < judgeVsAvgCumScores.length; i++) {
int r = (int)(Math.random() * rankBreakPoints.length);
judgeVsAvgCumScores[i] += rankBreakPoints[r];
}
}
sublevelId = CaveGen.specialCaveInfoName + "-" + CaveGen.sublevel;
// count expected number of treasures
expectedNumTreasures = 0;
expectedNumPokosPoD = 0;
expectedMaxCarry = 0;
for (Item t: g.spawnItem) {
expectedNumTreasures += t.min;
String name = t.itemName.toLowerCase();
expectedMaxCarry += Parser.maxCarry.get(name);
if (!ignoreTreasuresPoD.contains(name) && !optionalTreasuresPoD.contains(name)) {
expectedNumPokosPoD += Parser.pokos.get(name);
} else if (CaveGen.judgeType.equals("pod")) {
expectedMaxCarry -= Parser.maxCarry.get(name);
}
}
for (Teki t: g.spawnTekiConsolidated)
if (t.itemInside != null) {
expectedNumTreasures += t.min;
String name = t.itemInside.toLowerCase();
expectedMaxCarry += Parser.maxCarry.get(name);
if (!ignoreTreasuresPoD.contains(name) && !optionalTreasuresPoD.contains(name)) {
expectedNumPokosPoD += Parser.pokos.get(name);
} else if (CaveGen.judgeType.equals("pod")) {
expectedMaxCarry -= Parser.maxCarry.get(name);
}
}
if (sublevelId.equals("CH8-1")) expectedNumTreasures += 3;
if (sublevelId.equals("CH29-1")) expectedNumTreasures -= 1;
if (sublevelId.equals("CH21-1")) expectedNumTreasures += 3;
// count candypops
expectedNumQueenCandypop = 0;
expectedNumPurpleCandypop = 0;
expectedNumWhiteCandypop = 0;
for (Teki t: g.spawnTekiConsolidated) {
if (t.tekiName.equalsIgnoreCase("randpom")) expectedNumQueenCandypop += t.min;
if (t.tekiName.equalsIgnoreCase("blackpom")) expectedNumPurpleCandypop += t.min;
if (t.tekiName.equalsIgnoreCase("whitepom")) expectedNumWhiteCandypop += t.min;
}
if (sublevelId.equals("CH6-2")) previousNumQueenCandypop = 1;
else if (sublevelId.equals("CH26-2")) previousNumQueenCandypop = 3;
else if (sublevelId.equals("CH26-3")) previousNumQueenCandypop = 8;
else if (sublevelId.equals("CH30-4")) previousNumQueenCandypop = 3;
else if (sublevelId.equals("CH30-5")) previousNumQueenCandypop = 3;
else previousNumQueenCandypop = 0;
holeWorkMultiplier = 1;
geyserWorkMultiplier = 10;
candypopWorkMultiplier = 1;
rushBoots = false;
// calculate challenge mode piki counts
if (Parser.chPikiCount.containsKey(CaveGen.specialCaveInfoName + " 0")) {
float pikiCarrySum = 0;
float pikiAttackSum = 0;
float pikiStrengthSum = 0;
float pikiDigSum = 0;
fastestPikiCarryValue = 0;
pikiCount = 0;
boolean spicy = Parser.chSpicy.get(CaveGen.specialCaveInfoName) > 0;