-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIA.java
55 lines (37 loc) · 1.09 KB
/
IA.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
public class IA {
private final static double speed;
private final static double error;
private final static int green = 0;
private final static int white = 1;
private final static int blue = 2;
public void nextStep(){
int color = getColor();
int lc = speed; // left command
int rc = speed; // right command
switch(color) {
case green :
lc=lc+error;
rc=rc-error;
break;
case blue :
lc=lc-error;
rc=rc+error;
break;
}
sendCommand("left",lc);
sendCommand("right",rc);
}
public void bypassABlock(){
while(isABlock()) {
// rotate right 90°
// move forward for XX
// rotate left 90°
}
// move forward for XX
// rotate left 90°
while(getColor() != blue) {
// move forward until blue
}
// rotate right 90°
}
}