A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 3 years ago
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
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/

This Question is Closed

AGee
 3 years ago
Best ResponseYou've already chosen the best response.0in 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.

double_o_seven
 3 years ago
Best ResponseYou've already chosen the best response.0ok 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?

AGee
 3 years ago
Best ResponseYou've already chosen the best response.0In 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.

double_o_seven
 3 years ago
Best ResponseYou've already chosen the best response.0sorry I forgot to post my updated code: http://dpaste.com/hold/585061/

AGee
 3 years ago
Best ResponseYou've already chosen the best response.0I 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).

double_o_seven
 3 years ago
Best ResponseYou've already chosen the best response.0yeah 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
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.