Apple added CGPath boolean operations in iOS 16, macOS 13, etc. Awesome! Why was I not informed???
https://developer.apple.com/documentation/coregraphics/cgpath/3994964-intersection
Documented in the header file, but not in the docset.
Basic models of flocking behavior are controlled by three simple rules: 1) separation: avoid crowding neighbours (short range repulsion); 2) alignment: steer towards average heading of neighbors; 3) cohesion: steer towards average position of neighbors (long range attraction). With these three simple rules, the flock moves in an extremely realistic way.