Removing outliers from a group of mobs

Discussion in 'Spigot Plugin Development' started by SilverNinja555, May 16, 2019.

  1. I'm creating a zombie hoard plugin, while creating the pathfinder for them walking together, I realized i needed to find an average of their locations to find a place to walk near. But, the way I get rid of zombies that are stuck on walls is by saying if 80% of the other zombies in the hoard are >64 away, than he auto leaves the hoard. To calculate a good average for them to walk to, I should probably get rid of the outliers so that they don't walk towards zombies that are stuck. What is a good way to determine if a zombie is not part of/close to the hoard?
     
  2. For removing zombies, I would start off using an average, and check the distance from that. I wouldn't start off with a more complex check unless you know that you'll need it.

    I'd also recommend thinking about how you want your hoard to act.
    • Do you want your hoard to stay in a general area and target players?
    • Do you want your hoard to be constantly moving forward? I.e. if you had a minigame where the hoard was trying to advance towards a castle.
    • What are possible bad behaviors the hoard might exhibit? I.e. Clumping together, or forming a conga line. Maybe your ideal behavior is for all zombies to be going towards a target, and it's a bad behavior if Zombies are moving towards each other, like in a head on collision.
     
  3. I just want them to move randomly as a group and attack players when they see them, which doesn't require me to code. I finished the merging of hoards together, but still need the pathfinder for them to walk. I guess outliers don't matter too much, i just dont want 1 zombie to be stuck in a hole and another be just not moving, even though not stuck. I originally thought that if one was stuck, the other could walk around and merge hoards until that 1 zombie was kicked for being too far away, but im scared that the hoard will just sit there.

    Just another random question... I was planning to control the wandering by saying that they could move within like 10 blocks of the average, so that the average would slowly move and the hoard would move, so I was going to override g() in PathfinderGoalRandomStroll, but I don't understand what the parameters of RandomPositionGenerator.a() are. Could someone explain?
     
  4. For the outliers you could set up a boundary and remove them.

    Something like ... if target - mob > 63 || if mob - target > 63 remove mob

    As for stuck mobs, perhaps you can set up a movement or collisions method.
     

Share This Page