I am using python and a random() function for movement, but it looks like the
random() function is biased towards number less than 0.5 (less than zero in this case, since I am using the
Is there any way to fix this? Also, could you suggest a better way to simulate random but human movement?
def getNewPos(position): x = position y = position deltaX = random.uniform(-7.0, 7.0) deltaY = random.uniform(-7.0, 7.0) if x < 0: deltaX = -x elif x > width: deltaX = width - x elif x + deltaX > width or x + deltaX < 0: deltaX = -deltaX if y < 0: deltaY = -y elif y > height: deltaY = height - y elif y + deltaY > height or y + deltaY < 0: deltaY = -deltaY newX = int(x + deltaX) newY = int(y + deltaY) return (newX, newY)