I know this is an old question, but I noticed something and maybe it can be useful to someone, so ...
I think there is a problem here:
vx = (vx + self._rooms[_agent].startX - self._rooms[i].startX) * distance vy = (vy + self._rooms[_agent].startY - self._rooms[i].startY) * distance
Why do you multiply these equations by distance? " (self._rooms[_agent].startX - self._rooms[i].startX) " already contains (square) distance! Plus, multiplying everything by " distance ", you change your previous results stored in v! If at least you put "vx" outside the brackets, the result will only be higher, the normalization function will fix it. Although this useless calculation ...
By the way, I'm sure the code should look like this:
vx = vx + (self._rooms[_agent].startX - self._rooms[i].startX) vy = vy + (self._rooms[_agent].startY - self._rooms[i].startY)
I will give an example. Imagine that you have your main agent at (0,0) and three neighbors at (0, -2), (-2,0) and (0,2). The steering controls divide the main agent into the X axis in the normalized direction (1.0). Let it focus only on the Y-component of the result vector.
The math should be something like this:
--Iteration 1 vy = 0 + ( 0 + 2 ) --Iteration 2 vy = 2 + ( 0 - 0 ) --Iteration 3 vy = 2 + ( 0 - 2 ) --Result vy = 0
This is consistent with our theory. This is what your code does:
(note that the distance is always 2) --Iteration 1 vy = ( 0 + 0 + 2 ) * 2 --Iteration 2 vy = ( 4 + 0 - 0 ) * 2 --Iteration 3 vy = ( 8 + 0 - 2 ) * 2 --Result vy = 12
And if I got the correct separation behavior, it could not be right.