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

For those who have finished problem 11, do you see a difference when you set speed = 1.0 and speed > 1.0? For example, 1 robot(std strategy), in a 5x5 room, 100% coverage? I get speed of 1 or 2 the same number of time steps, more or less. Should it take half as many time steps with speed=2.0? Thanks

OpenStudy (anonymous):

Depends. Does your code depend on your floats being a whole number? For instance 1.0f == (float*float). ?

OpenStudy (anonymous):

Thanks for the quick reply, I am trying to think about what you wrote. :) If I set speed < 1.0 then it definitely takes more time steps than if I set speed=1.0. This 1.0f == (float*float) is a conditional? I didn't get it. Where I calculate the fraction of clean tiles I try to make sure the result is a float. I will double check.

OpenStudy (anonymous):

What im saying is that dont expect mathematical equations like 2.0f * 2.0 to == 4.0f. Also dont expect something like for x in range(100) i = 0.0f i + .01f if(i == 1.0f) code < dont assume this code is guaranteed to execute.

OpenStudy (anonymous):

because under the hood I ends up becoming .9999998 or some other rounding error type thing. So you may be stuck with (1.0f == .999998) which evaluates to false. Its best to give yourself room for rounding errors. (1.0f - .0001 >= i)

OpenStudy (anonymous):

also my loop up there is incorrect. the i = 0.0f needs to be outside the loop.

OpenStudy (anonymous):

also the f is there just to remind you that they are infact floating point numbers. You dont write them in python code.

OpenStudy (anonymous):

err range(101)* ive been coding with C# all day. :/

OpenStudy (anonymous):

Heres an example for you

OpenStudy (anonymous):

Thanks a lot for your help. I will be looking out for those comparisons in the code.

OpenStudy (maitre_kaio):

RogerDoger, are you trying to break the record of one line answers ? Are you targeting some OpenStudy achievement ? :-)

OpenStudy (anonymous):

If someone who has solved the problem would like to share his/her results, I would be very interested. In particular, the first test case mentioned in the ps11, part 3. 1 Robot (std strategy) speed=1.0 5x5 room 100% clean 100 trials How many time steps? Same conditions but speed = 2.0, speed = 3.0, speed=4.0, how many time steps in each case? Over here speed=2.0 is about the same and higher speeds actually take more time steps to clean the room, which doesn't seem right. If I set speed < 1.0 it also takes more time steps, which *does* make sense.

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!