DEV Community

Komal Gilani
Komal Gilani

Posted on

Python 100 Days Challange: Day 6 Project Reeborg Hurdle 4 Game

In the "Hurdle Race 4" challenge, Reeborg "Robort" faces the task of reaching a destination labeled as "at_goal" by navigating through a series of walls. The height of these walls remains unknown, requiring Reeborg to continuously move and perform jumps to overcome each obstacle. To successfully complete the challenge, there are specific rules and strategies that can guide Reeborg toward its destination:

  1. Sequential Movement and Jumps: Reeborg needs to employ a strategy of moving and jumping across each wall until it finally reaches the designated goal.

  2. Condition Checking for Movement and Jumps: When executing movement and jumps, Reeborg should perform condition checks to determine whether the path ahead or the wall in front is clear. This allows Reeborg to make informed decisions on when and how to move forward.

def turn_around():
    turn_left()


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

def move_and_jump_until_done():
    turn_left()
    while wall_on_right():   
        move()                # to move up 
    turn_right()
    move()
    turn_right()
    while front_is_clear():   #to move down
        move()
    turn_left()

while not at_goal():
    if wall_in_front():         # keep moving and jumping if there is wall
        move_and_jump_until_done()
    else:          # is there is no wall , just 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fncfabcm72erjskuzbel.png)move
        move()

Enter fullscreen mode Exit fullscreen mode

Top comments (0)