1234567891011121314151617181920212223242526272829303132333435363738 |
- public class EscapeBot extends Bot {
-
- boolean foundShip = false;
- boolean offByOne = true;
- int currentStepCount = 0;
- int steps = 0;
-
- public static void main(String[] args) {
- Bot bot = new EscapeBot(args);
- bot.run();
- }
-
- protected EscapeBot(String[] args) {
- super(args);
- }
-
- @Override
- protected char nextMove(View view) throws Exception {
- if (view.data.contains("o")) {
- int index = view.data.indexOf('o');
- if(index > view.width * 2) {
- return '^';
- }
- }
- if (steps == 0) {
- currentStepCount += 1;
- if(offByOne) {
- currentStepCount += 1;
- }
- offByOne = !offByOne;
- steps = currentStepCount;
- return '>';
- } else {
- steps -= 1;
- return '^';
- }
- }
- }
|