The first week of CS373 at Udacity was fun… and tough! Homework 1.4 is about the localization of a robot in a 2D red-and-green world, you have to calculate the probability distribution given the “world”, a list of measurements and a list of motions. Your sensor is pretty broken (senses right only 7 times out of 10) and the 2D robot really moves only four times out of five. You have to write some Python code that will calculate and show the distribution.
And the reason that I bothered tweaking it is that the modulo operator does not behave in the expected way for negative left-hand operand:
-1 % 5 == 1
while, according to Python, it should be 4. Also, booleans are not promoted to integers, so I patched those two things to make it work. If you’ve seen the code in Unit 1 you know why those patches are needed. Still, the modulo operator doesn’t work as expected for negative right-hand operators, but it really doesn’t matter in this case.