-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.java
More file actions
92 lines (81 loc) · 3.18 KB
/
Robot.java
File metadata and controls
92 lines (81 loc) · 3.18 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
import java.util.Scanner;
public class Robot {
boolean shootLowAuto = false;
boolean shootLowTele = false;
double autoAccuracy = 0.3; // percentage
double teleAccuracy = 0.3;
int secondsPerCycleAuto = 12;
int secondsPerCycleTele = 20;
int hangPoints = 4;
int hangTime = 30; // in seconds
public Robot() {
// prompt user here
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();
}
}
public Robot(boolean shootLowAuto, boolean shootLowTele, double autoAccuracy, double teleAccuracy,
int secondsPerCycleAuto, int secondsPerCycleTele, int hangPoints, int hangTime) {
this.shootLowAuto = shootLowAuto;
this.shootLowTele = shootLowTele;
this.autoAccuracy = autoAccuracy;
this.teleAccuracy = teleAccuracy;
this.secondsPerCycleAuto = secondsPerCycleAuto;
this.secondsPerCycleTele = secondsPerCycleTele;
this.hangPoints = hangPoints;
this.hangTime = hangTime;
}
public int pointsScored() {
int points = 0;
// Auto
int multiplier = 2;
if (!shootLowAuto) {
multiplier = 4;
}
double autoPoints = multiplier * (15 / secondsPerCycleAuto) * autoAccuracy;
points = (int) autoPoints;
// Tele
multiplier = 1;
if (!shootLowTele) {
multiplier = 2;
}
int teleShootingTime = 135 - hangTime;
double telePoints = multiplier * (teleShootingTime / secondsPerCycleTele) * teleAccuracy;
points += (int) telePoints;
// Endgame
points += hangPoints;
return points;
}
public int autoBallsScored() {
return (int) ((15 / secondsPerCycleAuto) * autoAccuracy);
}
public int teleopBallsScored() {
int teleShootingTime = 135 - hangTime;
return (int) ((teleShootingTime / secondsPerCycleTele) * teleAccuracy);
}
public int getHangPoints() {
return hangPoints;
}
}