RumbleBot unfinished
This commit is contained in:
parent
94f5f2bceb
commit
6bbe7e029b
60
src/RumbleBot.java
Normal file
60
src/RumbleBot.java
Normal file
@ -0,0 +1,60 @@
|
||||
public class RumbleBot extends Bot {
|
||||
|
||||
boolean foundShip = false;
|
||||
boolean offByOne = true;
|
||||
int currentStepCount = 0;
|
||||
int steps = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Bot bot = new RumbleBot(args);
|
||||
bot.run();
|
||||
}
|
||||
|
||||
protected RumbleBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char nextMove(View view) throws Exception {
|
||||
String data = view.data;
|
||||
int width = view.width;
|
||||
int height = data.length() / view.width;
|
||||
|
||||
data = data.replace('^', '*');
|
||||
data = data.replace('<', '*');
|
||||
data = data.replace('>', '*');
|
||||
data = data.replace('V', '*');
|
||||
System.out.println();
|
||||
|
||||
if (data.contains("*")) {
|
||||
int index = data.indexOf('*');
|
||||
if (index < view.width * height / 2 && !(index > view.width * height / 2 + 1)) {
|
||||
return safeMove(data);
|
||||
} else if (index % 5 < 2) {
|
||||
return '<';
|
||||
} else if (index % 5 > 2) {
|
||||
return '>';
|
||||
}
|
||||
return ' ';
|
||||
} else if (steps == 0) {
|
||||
currentStepCount += 1;
|
||||
if (offByOne) {
|
||||
currentStepCount += 1;
|
||||
}
|
||||
offByOne = !offByOne;
|
||||
steps = currentStepCount;
|
||||
return '>';
|
||||
} else {
|
||||
steps -= 1;
|
||||
return safeMove(data);
|
||||
}
|
||||
}
|
||||
|
||||
protected char safeMove(String data) {
|
||||
if ("~#X".contains("" + data.charAt(35))) {
|
||||
return '>';
|
||||
} else {
|
||||
return '^';
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user