## Basic Shortest Path algorithm

To conclude with this introductory lesson to maze solving algorithms, we will investigate another way to find the exit. The buggle in this lesson is a special buggle: he is a jedi. He can feel the Force. This means he is able to feel his environment.

Without even leaving his position, he can retrieve information about the world he is leaving in, with the following functions:

- `getWorldWidth()` gives the width of its world.
- `getWorldHeight()` gives the height of its world.
- `hasTopWall(x,y)` tells whether the cell (x,y) of this world has a wall on top.
- `hasLeftWall(x,y)` tells whether the cell (x,y) of this world has a wall on the left.
- `hasBaggle(x,y)` tells whether the cell (x,y) of this world has a baggle.
- `setIndication(x,y,i)` adds the integer indication `i` to the cell (x,y).
- `getIndication(x,y,i)` retrieves the integer indication of the cell (x,y) (or 9999 if there is no indication).

It has to be noted that it is not possible to build a wall on the bottom edge or on the right edge of a cell. Therefore when such wall exists, it means it was built on a sibling cells -- as a top (respectively left) wall on the cell that is located below (respectively at the right of) the current cell.

### Traguardo dell'esercizio

Your buggle should first write the distance to the exit on each cell (or at least the useful ones).
For that, find the exit and write 0 there. Then, write 1 on every neighboring cells that is not separated from the exit with a wall. And then mark every cells from which you can reach the exit in 2 steps, and iterate for all cells until all cells are marked.

Once the cells are marked, get your jedi buggle to follow the shortest path. Basically the buggle has only to walk on each case with the lesser distance from the exit. You can use the method `setDirection(direction)` to make your buggle look at the specific direction such as `[!scala|java|python]Direction.[/!]NORTH` or `[!scala|java|python]Direction.[/!]EAST`.

Use the Force, Luke!