# How to calculate random new position base on original position on map

I am making a 2D game with HTML5 Canvas. The game has several shapes and I want them to move all over the map randomly.

1. However, if I just give them a constant angle to follow, they will all end up in a corner after a certain amount of time.

2. Also, I am building this game with client-server so I don't want to send a lot of data. For example, I don't want to constantly update the angle on the server side and send it to the client.

That's why I want to generate a random position base on the shape's position on the big map.

For example, it's angle of movement will be tangent of it's (x,y). (It obviously won't work because it will get stuck on the sides of the map).

So what's a good way of generating the new coordinates base on it's current one?

xy nextPosition(seed, x, y)