> > > The technique was first described by Craig Reynolds in the 1980s and has > since then made it's way into many contemporary games. The algorithm is > interesting in that it's fairly computationally intensive. Each boid's > motion is determined by calculating it's distance from every other boid. If > the other boids are within a threshold, 3 different vector values (cohesion, > alignment, separation) are calculated based on the location and velocites > from all other boids that are within the said neighborhood. There's a lot > of interation, 67500 (150x150x3) iterations for 150 boids per update/render > loop. >
For the purpose of game development, I think it is a mistake to perform these calculations for every pair of birds. If you had an error of 1% in each of the three characteristics (cohesion, alignment, separation) would that still be good enough? Would this be an acceptable loss if you got a factor of 100 performance improvement? In "Objective CAML for Scientists" [1] pages 92-101 Jon Harrop demonstrates a rapid numerical solution for a multibody gravitation problem, which looks similar to the problem you are solving. He refers to the method as Fast Multipole Method [2,3]. It trades a little accuracy for a big performance gain. Oh, and his implementation in OCaml uses only immutable data structures. No guarantees, but I have a feeling that this would completely eliminate your performance issues. [1] http://www.ffconsultancy.com/products/ocaml_for_scientists/ [2] W. Rankin and J. Board, "A portable distributed implementation of the parallel multipole tree algorithm," in IEEE Symposium on High Performance Distributed Computing, (Los Alamitos), pp. 17-22, IEEE Computer Society Press, 1995. [3] http://en.wikipedia.org/wiki/Fast_Multipole_Method Sorry for the long post, definitely interested in how I could close the gap. > Of course I'm totally ready to accept the fact that this particular > algorithm is best suited for having parts written in Java, but I really > don't like Java and I love Clojure ;) > I think Clojure can handle this. Good luck :-D -- Education is what survives when what has been learned has been forgotten. - B. F. Skinner --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---