Snake World

We will now teach the buggle to explore its world. Its initial position is the bottom left corner, and it should visit any cells up to the top (coloring the ground on its path. The main loop of your code is something like:

 move brush down
 while we did not reach the final position
   move like a snake

We thus have to write two specific methods: The first one returns a boolean indicating whether we are on a final position while the second moves one snake step forward.

We reached the final position if and only if both conditions are true:

Then, a snake step can be achieved by moving one step forward if we are not facing a wall, and moving to the upper line else (i.e., if you look to the west facing a wall, you have to turn right, forward and turn right).

Hint: the main loop of your code must continue while the testing function returns false. There is two ways of writing it:

while (testingFunction() == [!c]0) {[/!][!java|scala]false) {[/!][!python]False):[/!]

[!python]You may prefer to write it as:[/!] [!java|scala|c]Since the exclamation mark (!) denotes the boolean negation in [!thelang], you may write it as:[/!]

while ([!java|scala|c]![/!][!python]not [/!]testingFunction())[!java|scala|c] {[/!][!python]:[/!]

Ваш хід…