DEV Community

Mike Kameta
Mike Kameta

Posted on • Edited on

100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 6 (Reeborgs World)

Reeborgs World The Hurdles Loop Challenge

https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%201&url=worlds%2Ftutorial_en%2Fhurdle1.json

def jump():
    move()
    turn_left()
    move()
    turn_right()
    move()
    turn_right()
    move()
    turn_left()

def turn_right():
    turn_left()
    turn_left()
    turn_left()

for step in range(6):
    jump()
Enter fullscreen mode Exit fullscreen mode

Reeborgs World Hurdle 2 - while function

def jump():
    move()
    turn_left()
    move()
    turn_right()
    move()
    turn_right()
    move()
    turn_left()

def turn_right():
    turn_left()
    turn_left()
    turn_left()

while not at_goal():
    jump()
Enter fullscreen mode Exit fullscreen mode

Reeborgs World - Hurdle 3

def turn_right():
    turn_left()
    turn_left()
    turn_left()

def jump():
    turn_left()
    move()
    turn_right()
    move()
    turn_right()
    move()
    turn_left()

while not at_goal():
    if wall_in_front():
        jump()
    else:
        move()
Enter fullscreen mode Exit fullscreen mode

Reborgs World - Hurdle 4

def turn_right():
    turn_left()
    turn_left()
    turn_left()

def jump():
    turn_left()
    while wall_on_right():
        move()
    turn_right()
    move()
    turn_right()
    while front_is_clear():
        move()
    turn_left()

while not at_goal():
    if wall_in_front():
        jump()
    else:
        move()
Enter fullscreen mode Exit fullscreen mode

Project 6 - Reeborgs Maze

def turn_right():
    turn_left()
    turn_left()
    turn_left()

while front_is_clear():
    move()
    turn_left()

while not at_goal():
    if front_is_clear() and wall_on_right():
        move()
    elif front_is_clear and right_is_clear():
        turn_right()
        move()
    elif front_is_clear():
        move()
    elif wall_in_front and right_is_clear():
        turn_right()
        move()
    else:
        turn_left()
Enter fullscreen mode Exit fullscreen mode

Note: As a beginner this was really hard for me. The instructions were that if I couldn't solve the problem then to leave this and wait until day 15 lessons then come back and do it again. I didn't listen lol and kept going to solve it. It took me a few hours of googling then understanding why the code had to be written this way. I ran the code a few times for testing and it worked, but will run it more as the maze changes every time.

Top comments (0)