my assignment is to create an algorithm for the karel robot to use to exit a maze and stop once it reaches a beeper. I have successfully created this algorithm except for getting karel to stop when it reaches the beeper. This is only a portion of my code, but you'll see that I'm basically inserting a beeper checkpoint at every step. I can't help but feel like there's an easier way, plus, when I tried executing with my newly inserted beeper checks, it gave me this error: Exception in thread "main" java.lang.StackOverflowError
while(!arg.rightIsClear() && arg.frontIsClear() && !arg.nextToABeeper())
{
arg.move();
}
if(arg.rightIsClear() && !arg.nextToABeeper())
{
arg.turnRight();
arg.move();
so, I would like to simply have an if statement that is checked at every interval throughout the program, if that is possible. thanks.