You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EscapeBot.java 899B

1234567891011121314151617181920212223242526272829303132333435363738
  1. public class EscapeBot extends Bot {
  2. boolean foundShip = false;
  3. boolean offByOne = true;
  4. int currentStepCount = 0;
  5. int steps = 0;
  6. public static void main(String[] args) {
  7. Bot bot = new EscapeBot(args);
  8. bot.run();
  9. }
  10. protected EscapeBot(String[] args) {
  11. super(args);
  12. }
  13. @Override
  14. protected char nextMove(View view) throws Exception {
  15. if (view.data.contains("o")) {
  16. int index = view.data.indexOf('o');
  17. if(index > view.width * 2) {
  18. return '^';
  19. }
  20. }
  21. if (steps == 0) {
  22. currentStepCount += 1;
  23. if(offByOne) {
  24. currentStepCount += 1;
  25. }
  26. offByOne = !offByOne;
  27. steps = currentStepCount;
  28. return '>';
  29. } else {
  30. steps -= 1;
  31. return '^';
  32. }
  33. }
  34. }