12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- public class RumbleBot extends Bot {
- 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 < width * height / 2 && index % width == 4) {
- return 'f';
- } else if (index < width * height / 2 && !(index > 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))) {
- currentStepCount = 2;
- return '>';
- } else {
- return '^';
- }
- }
- }
|