-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRaidsCompletion.java
More file actions
103 lines (93 loc) · 2.92 KB
/
Copy pathRaidsCompletion.java
File metadata and controls
103 lines (93 loc) · 2.92 KB
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
import java.util.*;
class RaidsCompletion {
// Weighting 20 (total 40)
int dex; int arc;
// Weighting 4 (total 8)
int buckler; int dhcb;
// Weighting 3 (total 15)
int claws; int ancHat; int ancTop; int ancLegs; int bulwark;
// Weighting 2 (total 6)
int kodai; int maul; int tbow;
int totalWeight = 69;
double pointRate = 867600;
double pointsPerRaid = 32000;
int c; // wanted completions, i am lazy and made it just c.
int totalRaids = 0;
Random rand = new Random(System.nanoTime());
public RaidsCompletion(int completions) {
c = completions;
}
public boolean isComplete() {
if ((dex >= c) && (arc >= c) && (buckler >= c) && (dhcb >= c) &&
(claws >= c) && (ancHat >= c) && (ancTop >= c) && (ancLegs >= c) && (bulwark >= c) &&
(kodai >= c) && (maul >= c) && (tbow >= c)) {
return true;
}
return false;
}
public void completeRaids() {
while (!isComplete()) {
totalRaids ++;
if (Math.random() <= (pointsPerRaid / pointRate)) {
int roll = rand.nextInt(totalWeight + 1);
if (roll <= 20) {
dex ++;
} else if (roll <= 40) {
arc ++;
} else if (roll <= 44) {
buckler ++;
} else if (roll <= 48) {
dhcb ++;
} else if (roll <= 51) {
claws ++;
} else if (roll <= 54) {
bulwark ++;
} else if (roll <= 57) {
ancHat ++;
} else if (roll <= 60) {
ancTop ++;
} else if (roll <= 63) {
ancLegs ++;
} else if (roll <= 65) {
kodai ++;
} else if (roll <= 67) {
maul ++;
} else if (roll <= 69) {
tbow ++;
}
}
}
}
public static void main(String[] args) {
int completions = 0;
int runs = 0;
try {
completions = Integer.parseInt(args[0]);
runs = Integer.parseInt(args[1]);
if ((completions <= 0) || (runs <= 0)) {
throw new Exception();
}
} catch (Exception e) {
System.out.println("nonon use 'java RaidsCompletion <c> <n>' where <c> is " +
"the number of completions you want, and <n> is the total" +
" number of simulations !!!");
return;
}
ArrayList<Integer> completionTime = new ArrayList<Integer>();
for (int i = 0; i < runs; i++) {
RaidsCompletion rc = new RaidsCompletion(completions);
rc.completeRaids();
completionTime.add(rc.totalRaids);
}
Collections.sort(completionTime);
long totalRaidCompletions = 0;
for (int i = 0; i < runs; i++) {
totalRaidCompletions += completionTime.get(i);
}
double average = totalRaidCompletions / runs;
System.out.println("Average: " + average);
System.out.println("Median: " + completionTime.get((int)(runs / 2)));
System.out.println("Best: " + completionTime.get(0));
System.out.println("Worst: " + completionTime.get(runs - 1));
}
}