diff --git a/src/RumbleBot.java b/src/RumbleBot.java index 54a66f3..d7f0dc8 100644 --- a/src/RumbleBot.java +++ b/src/RumbleBot.java @@ -24,12 +24,10 @@ public class RumbleBot extends Bot protected char nextMove(View view) { checkBarriers(view); - return walk(); - } - - //@TODO: add walk() logic - private char walk() - { + if (inDanger(view)) + { + //run away + } if(moves.isEmpty()) { moves += ' '; @@ -66,11 +64,11 @@ public class RumbleBot extends Bot int rightIndex = centerIndex + 1; - //these need to be changed to account for obstacles etc. - frontIsBlocked = view.data.charAt(frontIndex) == '*'; - backIsBlocked = view.data.charAt(backIndex) == '*'; - leftIsBlocked = view.data.charAt(leftIndex) == '*'; - rightIsBlocked = view.data.charAt(rightIndex) == '*'; + + frontIsBlocked = view.data.charAt(frontIndex) == '~' || view.data.charAt(frontIndex) == '#' || view.data.charAt(frontIndex) == 'X'; + backIsBlocked = view.data.charAt(backIndex) == '~' || view.data.charAt(frontIndex) == '#' || view.data.charAt(frontIndex) == 'X'; + leftIsBlocked = view.data.charAt(leftIndex) == '~' || view.data.charAt(frontIndex) == '#' || view.data.charAt(frontIndex) == 'X'; + rightIsBlocked = view.data.charAt(rightIndex) == '~' || view.data.charAt(frontIndex) == '#' || view.data.charAt(frontIndex) == 'X'; trapped = frontIsBlocked && backIsBlocked && leftIsBlocked && rightIsBlocked; } }