Browse Source

RumbleBot unfinished

master
Your Average Code 11 months ago
parent
commit
6bbe7e029b
1 changed files with 60 additions and 0 deletions
  1. 60
    0
      src/RumbleBot.java

+ 60
- 0
src/RumbleBot.java View File

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…
Cancel
Save