Tracks of buggles

Your buggle got lost in a strange maze, and you must help it to find the exit that is represented in orange. You cannot simply explain the path to the exit in something like right();forward();forward();forward() because you have to save two buggles at the same time, that are lost in similar but not identical worlds. You can switch to the other world by using the combobox above the world representation (where it's written 'Deep Forest' right now), and selecting the other entry (that should read 'Deeper Forest').

The good news is that the path to the exit is written on the ground. As you can see, the world is made of several corridors, with baggles on the ground. After each corridor, you should turn left if the corridor contains three baggels or more, and you have to turn right if there is only 2 baggles or less.

You should count exactly 5 cells per corridor, from intersection to intersection. Consider in your count the intersection ending the corridor but not the intersection before the corridor.

So, the general form of your code must be something like "while I did not find the exit, take the next corridor to decide whether I should turn left or right at the next intersection". You can determine whether you are on the exit cell (that is orange) with the provided exitReached() method.

To take one corridor, you simply have to run from one intersection to another while counting the baggles you see on your path. That's easy: there is 5 steps in each corridors so a simple for loop suffices.

You need a variable that is initialized to 0, and incremented each time you see a baggle on the ground. A variable used this way is often called counter.

Don't forget to reset your counter to 0 at the beginning of each corridor!

Oh, and when you reach the exit, don't forget to take an extra step to actually exit the maze!