# Help the robot come out of the maze

**URL:** <https://get-help.theconstruct.ai/t/help-the-robot-come-out-of-the-maze/24331>\
**Category:** Open Discussions\
**Created:** [May 14, 2023, 11:16am UTC](https://get-help.theconstruct.ai/t/help-the-robot-come-out-of-the-maze/24331 "2023-05-14T11:16:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![duygiangtemp](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@duygiangtemp](https://get-help.theconstruct.ai/u/duygiangtemp)\
**Post date:** [May 14, 2023, 11:16am UTC](https://get-help.theconstruct.ai/t/help-the-robot-come-out-of-the-maze/24331/1 "2023-05-14T11:16:29Z")

</div>

I’m looking for a solution to help the robot come out of the maze. However, my code when using the python command to run, nothing happens. Please help me  
Code:

```auto
from robot_control_class import RobotControl

robot_control = RobotControl()

def get_line():
    print("Start get line...")
    count = 719
    max_distance = 0
    max_position = 0

    while count > 0:
        count -= 1
        distance = robot_control.get_laser(count)
        if distance > max_distance:
            max_distance = distance
            max_position = count

    print("The max distance:", max_distance, "m")
    return max_position

def move(a):
    angle = (90 - (a / 719) * 180)
    robot_control.rotate(angle)
    robot_control.move_straight()
    if robot_control.get_laser(360) == 1:
        robot_control.stop_robot()

# Main loop
for c in range(6, 0, -1):
    temp = get_line()
    move(temp)

```

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [May 23, 2023, 8:22am UTC](https://get-help.theconstruct.ai/t/help-the-robot-come-out-of-the-maze/24331/2 "2023-05-23T08:22:04Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
