testing RumbleBot
This commit is contained in:
parent
e4dc5ec815
commit
4372c2a991
92
src/src/RumbleBot.java
Normal file
92
src/src/RumbleBot.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
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 '>';
|
||||||
|
}
|
||||||
|
}
|
31
src/src/test.java
Normal file
31
src/src/test.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package src;
|
||||||
|
|
||||||
|
public class test extends Bot{
|
||||||
|
|
||||||
|
String[] playerChars = {"<",">","^","v"};
|
||||||
|
|
||||||
|
protected test(String[] args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
test bot = new test(args);
|
||||||
|
bot.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected char nextMove(View view){
|
||||||
|
if(playerAhead(view)){
|
||||||
|
return 'f';
|
||||||
|
}
|
||||||
|
return '>';
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean playerAhead(View view){
|
||||||
|
for (String s : playerChars){
|
||||||
|
if(view.data.substring(4,5).contains(s) || view.data.substring(13,14).contains(s)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user