From 6bbe7e029b6432222f56f35cb28547f5335a9534 Mon Sep 17 00:00:00 2001 From: Your Average Code <138674451+UrAvgCode@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:00:49 +0100 Subject: [PATCH] RumbleBot unfinished --- src/RumbleBot.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/RumbleBot.java diff --git a/src/RumbleBot.java b/src/RumbleBot.java new file mode 100644 index 0000000..6285471 --- /dev/null +++ b/src/RumbleBot.java @@ -0,0 +1,60 @@ +public class RumbleBot extends Bot { + + boolean foundShip = false; + boolean offByOne = true; + int currentStepCount = 0; + int steps = 0; + + public static void main(String[] args) { + Bot bot = new RumbleBot(args); + bot.run(); + } + + protected RumbleBot(String[] args) { + super(args); + } + + @Override + protected char nextMove(View view) throws Exception { + String data = view.data; + int width = view.width; + int height = data.length() / view.width; + + data = data.replace('^', '*'); + data = data.replace('<', '*'); + data = data.replace('>', '*'); + data = data.replace('V', '*'); + System.out.println(); + + if (data.contains("*")) { + int index = data.indexOf('*'); + if (index < view.width * height / 2 && !(index > view.width * height / 2 + 1)) { + return safeMove(data); + } else if (index % 5 < 2) { + return '<'; + } else if (index % 5 > 2) { + return '>'; + } + return ' '; + } else if (steps == 0) { + currentStepCount += 1; + if (offByOne) { + currentStepCount += 1; + } + offByOne = !offByOne; + steps = currentStepCount; + return '>'; + } else { + steps -= 1; + return safeMove(data); + } + } + + protected char safeMove(String data) { + if ("~#X".contains("" + data.charAt(35))) { + return '>'; + } else { + return '^'; + } + } +}