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

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