forked from get-flord/Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
executable file
·59 lines (51 loc) · 1.69 KB
/
Copy pathMain.java
File metadata and controls
executable file
·59 lines (51 loc) · 1.69 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
package clanmelee;
import java.util.Collection;
import java.util.Random;
public class Main {
private static Random rand = new Random();
/**
* Wiggles the number of hitPoints that will actually be used by a small margin
* @param original
* @return
*/
private static int wiggle(int original)
{
int amount = rand.nextInt((int) (original * 0.05));
if (rand.nextDouble() < 0.5)
{
return original + amount;
}
else
{
return original - amount;
}
}
/**
* Runs the simulation where the BaseHitPoints are given in an array and the for loop goes through all instances in
* order to finish all of the simulations
* @param args
*/
public static void main(String[] args) {
int[] allBaseHitPoints = {100, 1000, 10000, 100000, 1000000, 10000000};
Collection<Clan> clans = new ClanFactory().getClans();
ClanMelee melee = new ClanMelee();
int round = 1;
// Runs for all of the HitPoint instances given in the Array
for (int baseHitPoints : allBaseHitPoints)
{
for (int i = 0; i < 5; i++)
{
int hitPoints = wiggle(baseHitPoints);
System.out.println("Round " + round + ", " + hitPoints + " hit points per clan");
System.out.println();
// Runs the Melee
melee.runMelee(clans, hitPoints);
System.out.println();
System.out.println("Results after " + round + " rounds:");
melee.printStats();
System.out.println();
++round;
}
}
}
}