Table Of Contents

Previous topic

23. Refinements: part 2

Next topic

25. Refinements: part 4

This Page

24. Refinements: part 3

As you should have noticed the program doesn’t work. What happens is that Reeborg gets in an infinite loop when there is no wall around him. We need to have him move() after turning right, as indicated below:

put("token");
move();
while ( !token_here() ){
    if (right_is_clear()){
        turn_right();
        move();
    } else if (front_is_clear()){
        move();
    } else {
        turn_left();
    }
}

24.1. More complicated world

Another world!

Now, consider Around 3; will our program work?

As you probably guessed, unfortunately the answer is no. Try to figure out why before reading any further.