-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
185 lines (155 loc) · 7.12 KB
/
Test.java
File metadata and controls
185 lines (155 loc) · 7.12 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
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
import java.util.ArrayList;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Run Game(0) or Optimize Shooting(1)?");
if (input.nextInt()==0) {
runGame();
} else optimizeShooting();
}
public static void optimizeShooting(){
boolean shootLowAuto = true;
boolean shootLowTele = false;
double autoAccuracy = 0.5; // percentage
double teleAccuracy = 0.5;
int secondsPerCycleAuto = 5;
int secondsPerCycleTele = 10;
int hangPoints = 6;
int hangTime = 30; // in seconds
Robot robot1;
Robot robot2;
System.out.println("For YOUR ROBOT: ");
Scanner input = new Scanner(System.in);
System.out.println("Will it shoot low for auto? (2 = All defaults, 1 = yes, 0 = no)");
int lowAuto = input.nextInt();
if (lowAuto < 2) {
if (lowAuto == 1) {
shootLowAuto = true;
}
// System.out.println("Will it shoot low for tele? (1 = yes, 0 = no)");
// int lowTele = input.nextInt();
// if (lowTele == 1) {
// shootLowTele = true;
// }
System.out.println("Auto accuracy (a decimal between 0 and 1): ");
autoAccuracy = input.nextDouble();
System.out.println("Teleop accuracy (a decimal between 0 and 1): ");
teleAccuracy = input.nextDouble();
System.out.println("How many seconds does a cycle take in AUTO? (integer)");
secondsPerCycleAuto = input.nextInt();
System.out.println("How many seconds does a cycle take in TELEOP? (integer)");
secondsPerCycleTele = input.nextInt();
System.out.println("How many hang points will the robot get? (0, 4, 6, 10, 15)");
hangPoints = input.nextInt();
System.out.println("How many seconds will it take for your robot to hang? (integer)");
hangTime = input.nextInt();
}
System.out.println("Alliance Member #1: ");
robot1 = new Robot();
System.out.println("Alliance Member #2: ");
robot2 = new Robot();
float totalRPs = 0;
float totalPoints = 0;
int totalWins = 0;
for (int i = 0; i < Constants.NUM_GAMES; i++) {
ArrayList<Robot> redAlliance = new ArrayList<Robot>();
for (int x = 0; x < 3; x++) {
redAlliance.add(Game.randomizeRobot());
}
ArrayList<Robot> blueAlliance = new ArrayList<Robot>();
blueAlliance.add(robot1);
blueAlliance.add(robot2);
blueAlliance.add(new Robot(shootLowAuto, shootLowTele, autoAccuracy, teleAccuracy, secondsPerCycleAuto, secondsPerCycleTele, hangPoints, hangTime));
Game game = new Game(blueAlliance, redAlliance);
totalRPs += game.getBlueAllianceRPs();
totalPoints += game.getBlueAlliancePoints();
if (game.winner() == "Blue Alliance") {
totalWins++;
}
}
System.out.print("SHOOT LOW TELE SUMMARY: ");
System.out.print("TOTAL WINS: " + totalWins + " / " + Constants.NUM_GAMES);
System.out.print(", AVERAGE RANKING POINTS: " + (totalRPs / Constants.NUM_GAMES));
System.out.println(", AVERAGE (ALLIANCE) POINTS: " + (totalPoints / Constants.NUM_GAMES));
totalRPs = 0;
totalPoints = 0;
totalWins = 0;
shootLowTele = false;
for (int i = 0; i < Constants.NUM_GAMES; i++) {
ArrayList<Robot> redAlliance = new ArrayList<Robot>();
for (int x = 0; x < 3; x++) {
redAlliance.add(Game.randomizeRobot());
}
ArrayList<Robot> blueAlliance = new ArrayList<Robot>();
blueAlliance.add(robot1);
blueAlliance.add(robot2);
blueAlliance.add(new Robot(shootLowAuto, shootLowTele, autoAccuracy, teleAccuracy, secondsPerCycleAuto, secondsPerCycleTele, hangPoints, hangTime));
Game game = new Game(blueAlliance, redAlliance);
totalRPs += game.getBlueAllianceRPs();
totalPoints += game.getBlueAlliancePoints();
if (game.winner() == "Blue Alliance") {
totalWins++;
}
}
System.out.print("SHOOT HIGH TELE SUMMARY: ");
System.out.print("TOTAL WINS: " + totalWins + " / " + Constants.NUM_GAMES);
System.out.print(", AVERAGE RANKING POINTS: " + (totalRPs / Constants.NUM_GAMES));
System.out.println(", AVERAGE (ALLIANCE) POINTS: " + (totalPoints / Constants.NUM_GAMES));
input.close();
}
public static void runGame(){
ArrayList<Robot> fixedBlueAlliance = new ArrayList<Robot>();
Boolean randomizeAlliance = false;
System.out.println("For YOUR ROBOT: ");
Robot myRobot = new Robot();
Scanner input = new Scanner(System.in);
System.out.println("Randomize Alliance? - Random (0) or Specified (1)?");
if (input.nextInt()==0) {
randomizeAlliance = true;
}
if (!randomizeAlliance){
fixedBlueAlliance.add(myRobot);
System.out.println("Alliance Member #1: ");
fixedBlueAlliance.add(new Robot());
System.out.println("Alliance Member #2: ");
fixedBlueAlliance.add(new Robot());
}
float totalRPs = 0;
float totalPoints = 0;
int totalWins = 0;
for (int i = 0; i < Constants.NUM_GAMES; i++) {
ArrayList<Robot> redAlliance = new ArrayList<Robot>();
for (int x = 0; x < 3; x++) {
redAlliance.add(Game.randomizeRobot());
}
ArrayList<Robot> blueAlliance = new ArrayList<Robot>();
if (randomizeAlliance)
{
blueAlliance.add(myRobot);
blueAlliance.add(Game.randomizeRobot());
blueAlliance.add(Game.randomizeRobot());
}
else{
blueAlliance = fixedBlueAlliance;
}
System.out.print("Game #" + (i + 1) + ": ");
Game game = new Game(blueAlliance, redAlliance);
totalRPs += game.getBlueAllianceRPs();
totalPoints += game.getBlueAlliancePoints();
System.out.print("Red Points: " + game.getRedAlliancePoints() + "; RPs: "
+ game.getRedAllianceRPs());
System.out.print(" | Blue Points: " + game.getBlueAlliancePoints() + "; RPs: "
+ game.getBlueAllianceRPs());
System.out.println(" | WINNER: " + game.winner());
if (game.winner() == "Blue Alliance") {
totalWins++;
}
}
System.out.print("SUMMARY: ");
System.out.print("TOTAL WINS: " + totalWins + " / " + Constants.NUM_GAMES);
System.out.print(", AVERAGE RANKING POINTS: " + (totalRPs / Constants.NUM_GAMES));
System.out.println(", AVERAGE (ALLIANCE) POINTS: " + (totalPoints / Constants.NUM_GAMES));
input.close();
}
}