Flocking with a SheepDog
The sheep behaviour in this sim is the same as in the first flocking applet, except now they also take into account their distance from a sheep dog (the cyan colored square). If the dog is far enough away, they just flock like normal, but if the dog gets too close they will disperse until they are comfortable and then attempt to get as close to each other as possible.
Move the sheep dog by clicking anywhere on the applet. If you hold down the ctrl key while clicking, you will give the flock a point to go to. They will try to get to that point as long as it doesn't mean they go too close to the dog.