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.

RumbleBot.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. public class RumbleBot 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 RumbleBot(args);
  7. bot.run();
  8. }
  9. protected RumbleBot(String[] args) {
  10. super(args);
  11. }
  12. @Override
  13. protected char nextMove(View view) throws Exception {
  14. String data = view.data;
  15. int width = view.width;
  16. int height = data.length() / view.width;
  17. data = data.replace('^', '*');
  18. data = data.replace('<', '*');
  19. data = data.replace('>', '*');
  20. data = data.replace('V', '*');
  21. System.out.println();
  22. if (data.contains("*")) {
  23. int index = data.indexOf('*');
  24. if (index < width * height / 2 && index % width == 4) {
  25. return 'f';
  26. } else if (index < width * height / 2 && !(index > width * height / 2 + 1)) {
  27. return safeMove(data);
  28. } else if (index % 5 < 2) {
  29. return '<';
  30. } else if (index % 5 > 2) {
  31. return '>';
  32. }
  33. return ' ';
  34. } else if (steps == 0) {
  35. currentStepCount += 1;
  36. if (offByOne) {
  37. currentStepCount += 1;
  38. }
  39. offByOne = !offByOne;
  40. steps = currentStepCount;
  41. return '>';
  42. } else {
  43. steps -= 1;
  44. return safeMove(data);
  45. }
  46. }
  47. protected char safeMove(String data) {
  48. if ("~#X".contains("" + data.charAt(35))) {
  49. currentStepCount = 2;
  50. return '>';
  51. } else {
  52. return '^';
  53. }
  54. }
  55. }