defsense(p, Z): q = [] for i inrange(len(p)): hit = (Z == world[i]) q.append(p[i] * (hit * pHit + (1-hit) * pMiss)) s = sum(q) for i inrange(len(p)): q[i] = q[i]/s return q
defmove(p, U): q = [] for i inrange(len(p)): s = pExact * p[(i-U) % len(p)] s = s + pOvershoot * p[(i-U-1) % len(p)] s = s + pUndershoot * p[(i-U+1) % len(p)] q.append(s) return q
for k inrange(len(measurements)): p = sense(p, measurements[k]) p = move(p, motions[k]) print p