Getting Started with Laby

Getting Started with Laby#

  1. Run the cell below to display a maze. The following cell contains a program to guide the ant out of the maze by giving it a series of simple commands: move forward, turn right, etc. Along the way, the ant will have some fun with the pebble and avoid the spider web.

  2. Run the program. Hint: use Ctrl-Enter to avoid moving to the next cell.

  3. Use the maze’s control buttons to follow the program’s execution step-by-step, in reverse, etc., to fully understand what the ant is doing.

  4. Refer to the documentation below. The elements described there will be useful to you progressively as you tackle the challenges. You will come back to consult it regularly.

  5. Proceed to the next level.

from laby.global_fr import *
Laby(niveau="0")
debut()
droite()
avance()
prend()
gauche()
avance()
pose()
droite()
avance()
gauche()
avance()
avance()
droite()
ouvre()

Documentation#

Hint

Constants

Mur Sortie
Caillou PetitCaillou
Toile PetiteToile
Vide Inconnu
^^^html_block

Hint

Instructions

    debut()         # Recommence le niveau

    avance()        # Fait un pas vers l'avant
    droite()        # Fait pivoter la fourmi vers la droite
    gauche()        # ou la gauche
    prend()         # Prend le caillou situé sur la case devant la fourmi
    pose()          # Pose le caillou devant la fourmi
    dit("bonjour")  # Dit bonjour
    regarde()       # Renvoie Vide, Caillou, PetitCaillou, Mur,
                    # Toile, PetiteToile, Sortie, ou Inconnu
                    # selon ce qui se trouve sur la case devant la fourmi

    ouvre()         # Ouvre la porte située devant la fourmi (fin du niveau)

Hint

Some Python elements As long as the condition is true, repeat the instructions:

    while condition:
        instructions

If the condition is true, execute instructions 1, otherwise instructions 2:

    if condition:
        instructions1
    else:
        instructions2

Definition of a function ma_fonction:

    def ma_fonction():
        instructions

for loop with counter; here to count from 0 to 4 inclusive:

    for i in range(5):
        instructions