0

I have been trying to solve the rain2.wld file in the cs1robots module. here is the code:

from cs1robots import *

load_world("rain2")
h = Robot(avenue=3, street=6, orientation='S', beepers=10)
h.set_trace("blue")
h.set_pause(0.3)

h.drop_beeper()
h.move()

while not h.on_beeper():
    if h.right_is_clear():
        h.drop_beeper()
        h.move()
    elif h.front_is_clear():
        h.move()
    elif h.left_is_clear():
        h.turn_left()

output of the code

i wanted it to check for every "window" and place a beeper there. but this is not doing it.

This is the output that i am going for is: planned output

4
  • "but this is not doing it". What exactly is it doing? Commented Nov 28, 2024 at 6:01
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Nov 28, 2024 at 7:22
  • @ewokx i modified my question by adding the output that i am trying to achieve. hopefully that helps. thanks Commented Nov 29, 2024 at 8:53
  • The problem is you can't just check if right is clear, because instead of a window it might be the wall turning. You could solve this by driving the robot down and checking if there are more walls, but you want to have the path described in planned output. What functions does the robot have access to? (on_beeper(), front_is_clear(), etc) If you can send those I can help you write a better program. Commented Jul 1 at 19:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.