Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

double_o_seven Group Title

Hi Im back again. Im working on ps11 #4. Im confident that my problem is in my baseRobot class more specifically my isPositionInRoom function under rectangularRoom. can anyone help me debug this? isPostionInRoom isn't returning true when it should and is causing me to go infinite loop on line 244. Here's my code thus far: http://dpaste.com/hold/584037/

  • 3 years ago
  • 3 years ago

  • This Question is Closed
  1. AGee Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    in your RectangularRoom class, the method isPositionInRoom is a function of whether a tile is clean or not. Instead, it should be a function of whether pos is within the rectangular room boundaries. Also, I think pos are floats and are not necessarily integer tile coordinates, which affects your cleanTileAtPosition method.

    • 3 years ago
  2. double_o_seven Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ok so i think i sort of get what your saying.... I did this to combat the isPositionInRoom problem and the pos problem. However, my room doesn't get clean.... and it takes forever. I'm thinking that it's my while loop on line 256.... Any suggestions on how to combat this?

    • 3 years ago
  3. AGee Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    In your updatePositionAndClean method you call genNewPosition in the while loop. In isPositionInRoom, you have the input position defined as integer pair (m,n). But getNewPosition returns position as float pair (x,y) which is unlikely to be an integer pair and thus not in the room. I think the program intent is for position to be a float pair (x,y). In cleanTileAtPosition, you probably want to take the (x,y) float pair and quantize it to a (m,n) tile.

    • 3 years ago
  4. double_o_seven Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    sorry I forgot to post my updated code: http://dpaste.com/hold/585061/

    • 3 years ago
  5. AGee Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I think your problem is still in the while loop. getNewPosition moves the robot to a new location based on the current location, direction, and speed. If the robot goes outside the room, you randomly change the direction, but this could move the robot further from the room, and since it is random, there is a chance the robot won't find it's way back to the room (and exit the while loop).

    • 3 years ago
  6. double_o_seven Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah I noticed that and also found another primary bug. thanks anyway and heres what I have for #4: http://dpaste.com/hold/586361/ Now im trying to get the whole pylab thing :O

    • 3 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.