Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 11 Online
OpenStudy (anonymous):

I'm having some problems with Problem Set 6; I can't seem to get my updatePositionAndClean method to work. What I want to happen is the following: * set new direction * set new position * convert new position co-ordinates into int * i.e. 1.3234243, 6.3234234 --> 1, 6 * This represents the Tile position the robot is on * Check against dirty tiles *etc

OpenStudy (anonymous):

Code:- http://pastebin.com/bnjvt1qR Error:- Traceback (most recent call last): File "<ipython-input-287-04130fe2a9f5>", line 1, in <module> jimmy.updatePositionAndClean() File "/home/nixoninnes/python/MIT OCW/Introduction to Computer Science and Programming/Problem Set 6/ps6.py", line 226, in updatePositionAndClean self.position = self.position.getNewPosition(self.getRobotDirection,1) File "/home/nixoninnes/python/MIT OCW/Introduction to Computer Science and Programming/Problem Set 6/ps6.py", line 43, in getNewPosition delta_y = speed * math.cos(math.radians(angle)) TypeError: a float is required

OpenStudy (anonymous):

TypeError: a float is required You want an integer and Python wants a float. Give it a float and see what happens.

OpenStudy (anonymous):

Yah, I played around with it for a while and managed to sort my problem. Off the top of my head I can't remember where I'd slipped up. I'll stick a link in to my solution later :)

OpenStudy (anonymous):

If you're still interested, here's my files... I re-wrote a section in ps6_visualise.py because I changed the input parameters of isTileCleaned() to take a Position, since my whole program is communicating with a Position class it made no sense to suddenly start handing around a set of ints... ps6.py: http://pastebin.com/ne8n0v7z ps6_visualise: http://pastebin.com/aGercbJw

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!