93 lines
2.2 KiB
Java
93 lines
2.2 KiB
Java
package src;
|
|
|
|
public class RumbleBot extends Bot{
|
|
|
|
|
|
String[] playerChars = {"<",">","^","v"};
|
|
int angle = 0;
|
|
int x = 0;
|
|
int y = 0;
|
|
boolean left = false;
|
|
boolean right = false;
|
|
boolean up = false;
|
|
boolean down = false;
|
|
int turnCounter = 0;
|
|
int waitTimer = 80;
|
|
|
|
protected RumbleBot(String[] args) {
|
|
super(args);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
RumbleBot bot = new RumbleBot(args);
|
|
bot.run();
|
|
}
|
|
|
|
protected char nextMove(View view){
|
|
|
|
if(waitTimer > 0){
|
|
waitTimer--;
|
|
return 0;
|
|
}
|
|
//back away if possible
|
|
if(playerAhead(view) && !view.data.substring(49,50).contains("X")){
|
|
return 'v';
|
|
}
|
|
//shoot target
|
|
if(playerAhead(view)){
|
|
return 'f';
|
|
}
|
|
|
|
if(view.data.substring(39,40).contains("X") && view.data.substring(49,50).contains("X")){
|
|
return '^';
|
|
}else turnRight();
|
|
// if (x <= 15 && !up){
|
|
// x++;
|
|
// return '^';
|
|
// }else if(angle != 180){
|
|
// up = true;
|
|
// return turnRight();
|
|
// }else if (x >= -15 && !down){
|
|
// x--;
|
|
// return '^';
|
|
// } else if (angle != 0) {
|
|
// down = true;
|
|
// return turnRight();
|
|
// }else if (x < 0){
|
|
// x++;
|
|
// return '^';
|
|
// } else if (angle != 90 && x == 0) {
|
|
// return turnRight();
|
|
// } else if (y <= 15 && !right) {
|
|
// y++;
|
|
// return '^';
|
|
// } else if (angle != 270) {
|
|
// right = true;
|
|
// return turnRight();
|
|
// } else if(y >= -15 && !left){
|
|
// y--;
|
|
// return '^';
|
|
// }else if(angle != 90){
|
|
// turnRight();
|
|
// }else if (y > 0){
|
|
// y++;
|
|
// return '^';
|
|
// }
|
|
return 0;
|
|
}
|
|
|
|
private boolean playerAhead(View view){
|
|
for (String s : playerChars){
|
|
if(view.data.substring(4,5).contains(s) || view.data.substring(43,45).contains(s)){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private char turnRight(){
|
|
angle = (angle + 90) % 360;
|
|
return '>';
|
|
}
|
|
}
|