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 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. public class EscapeBot extends Bot {
  2. boolean foundShip = false;
  3. boolean offByOne = true;
  4. int currentStepCount = 0;
  5. int steps = 10;
  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. System.out.println();
  16. if (view.data.contains("o")) {
  17. int index = view.data.indexOf('o');
  18. if (index < view.width * 2 && !(index > view.width * 3)) {
  19. return '^';
  20. } else if (index % 5 < 2) {
  21. return '<';
  22. } else if (index % 5 > 2) {
  23. return '>';
  24. }
  25. return ' ';
  26. } else if (steps == 0) {
  27. currentStepCount += 1;
  28. if (offByOne) {
  29. currentStepCount += 1;
  30. }
  31. offByOne = !offByOne;
  32. steps = currentStepCount;
  33. return '>';
  34. } else {
  35. steps -= 1;
  36. return '^';
  37. }
  38. }
  39. }