anonymous
  • anonymous
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/
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
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.
anonymous
  • anonymous
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?
anonymous
  • anonymous
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.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
sorry I forgot to post my updated code: http://dpaste.com/hold/585061/
anonymous
  • anonymous
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).
anonymous
  • anonymous
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

Looking for something else?

Not the answer you are looking for? Search for more explanations.