Random Mazes#
The command below creates a random maze. There is always a path to the
exit and no loops. Can you write a program that will always get you out
of the maze?
Attention
This exercise is marked with a ♣ and is therefore of a more advanced level; do not hesitate to skip it if it seems difficult to you in order to not waste too much time, and to come back to it later.
Let’s start small…#
from laby.global_fr import *
Laby(lignes = 2, colonnes = 2)
debut()
from laby.global_fr import *
Laby(lignes = 3, colonnes = 3)
debut()
The real challenge#
Indication
Implement the right-hand rule strategy: the ant follows a wall, the one on its right
(or on its left), and moves forward until it finds the exit. Note: this algorithm only
works on so-called perfect labyrinths, i.e. those that do not contain
islands, loops or inaccessible cells.
from laby.global_fr import *
Laby(lignes = 8, colonnes = 8)
debut()
Even more of a challenge!#
It is possible to add options to have pebbles and webs!
For example:
from laby.global_fr import *
Laby(lignes = 8, colonnes = 8, option = "fullRocks")
debut()
Possible options: rocks, webs, fullRocks, fullWebs, rocksAndWebs, fullRocksAndWebs