![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I finally got my Javascript implementation of Craig Reynolds's boids algorithm to work. Here is the relevant code:
var weights= new Array(1.0, 1.0, 1.0); sepvect = sepvect.multiply(weights[0]); alivect = alivect.multiply(weights[1]); cohvect = cohvect.multiply(weights[2]);
I just needed to record magnitudes for one run and fiddle with the weights. (0.5,1.0,0.2) seemed to do the trick, though I should test with different numbers of boids to see if the magnitudes are relative to that variable.
As regards "finally", I started on this so long ago that I forget when and have intermittently picked it up and re-abandoned it since then. The oldest timestamp that I can find for it is 2006, but I think it goes back to 2003 or 2004 when it was going to be something that I would put together during spring break. The biggest problem was a trig error that I fixed last month after having almost fixed it earlier, causing directions to be wrong in one or two of the four quadrants.