Log In  


Cart #boids8_19-0 | 2022-01-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4


A simple boids simulation. You can open it in the editor to tweak the settings even further

there are no controls in this cart, but you might want to turn off carts in the menu

4


2

Hi! Neat idea, I love these kinds of toy systems. A couple of observations:

  • The boids don't really seem to be flocking - have you found parameter settings that make them do this?

  • There are a lot of degree-scaled angles here, which makes me suspicious. For example: atan2 will never return a value over 180.

  • That sqrt is probably unnecessary, and since it's happening for every pair of boids it's taking a lot of time. Maybe do squared distance comparisons instead?

  • More minor optimization notes: use ipairs to get indices for each boid so you can skip drawing unnecessary lines (from lower to higher only, or vice versa). Could also re-use a pair's distance computation the second time you see it, or just accumulate into both members of a pair at once. Don't build up lists of things to average later, when you can just keep a running total and a count in the loop. Declare variables as local when possible.

1

It's like possessed Christmas Lights. Really beautiful and mesmerizing to watch. You have my star. It is your first surely to be of many.


pog. just pog.



[Please log in to post a comment]