@Dodolulupepe ask me via pm how to calculate the center of a region defined by a group of objects.
So, I put this small project together. In this mini-game you can spawn flies by clicking on the background and kill flies by clicking over them. Also, you can press [R] to toggle on/off a frame showing the boundaries and the center of the region occupied by the flies.
By default, it also shows a very primitive IA (just flies flying around from one point to anoter) that allows each fly to have it own random pattern.