NetLogo banner

 NetLogo Publications
 Contact Us

 Modeling Commons

 User Manuals:
 Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

Try It in NetLogo Web


The aim of this model to investigate the interactions between a sheep herd and one or several sheepdogs.

The goal is to see the effect of different foward steering strategies that sheepdogs can use to steer a flock of sheeps as a whole towards a given direction.


We have configured the Bird flocking model already available in Netlogo so that the flock behavior looks more like a sheep herd surrounded by a preadator (sheepdog here). The behavior of flocks of sheeps is very similar to flock of birds or insects and is called "herding". Herding also follows the three rules: "alignment", "separation", and "cohesion", with little differences:

- The "cohesion" parameter is by far the most important behavior. It is stronger than in birds formations. The trend of the herd to form a coherent flock is controlled by the "force-of-cohesion" parameter which represents the vision which allows sheep to see its neighborhood at 360 degree and quickly join the herd if it is separated from it.

- The minimum separation distance is set to a very small value. Unlike birds , we consider that sheep can stay tightly packed.

"Alignment" means that a sheep tends to turn so that it is moving in the same direction that nearby sheep are moving. This behavior is not as important as for the birds as sheep do not fly , therefore do not have to move all the time. This is expressed in the model by a very small max-align-turn paramùeter

We have considered that the herd is already almost gathered at the initialisation and that the sheepdog can focus on "steering" the herd.

In a more realistic situation, the sheepdog would need to gather some separated sheeps or some sub_herds to create an homogeneous herd before starting the steering phase. "Gathering strategies" are not explicitely addressed in the model (see possible extensions), we only focus on the "steering" phase even if "gathering" can occur as an emergent herd behavior caused by the sheepdog formation (observed in arc formations).

The herding model has been extended to include the fear and repulsion caused by the sheepdog on the sheep.

When the sheepdog is within a certain flight zone from a sheep, the three behaviors are replaced by a "fleeing" behavior. "fleeing" works the same way as the separation behavior.

Separation sheep behavior consists of turning away from the direction the sheepdog is heading to. The magnitude of the resulting separation deplacement is controlled by a "fear_of_dog" parameter which can represent the emotional response of the sheep or the agressivity of the dog

A Forward steering technique is used to steer the herd as a whole by exercising a force of repulsion on the herd centroid. First the sheepdog is moving in straight line to a steering point calculated so that it is aligned with the herd centroid and the steering direction (always north in this model). Once the sheepdog has moved to the steering point, it moves slightly foward to enter the flight zone, which may disturb the herd depending on the sheep fear reaction. The new steering point is calculated again and the operation is repeated.

The number of shepedogs can vary from 0 (no dogs, herd moving erraticaly) to 5 dogs

Different strategies and formations can be tested:
- Line formation : Dogs form a line pependicular to the South-north direction. The steering point is the middle of the formation
- side-to-side : A single dog is constantly running from a side of the herd to the other around the steering point
- Arc formation : Dogs form a partial circle. The steering point is the lower point in the circle


First, determine the number of sheeps you want in the simulation and the number of sheepdogs. Press SETUP to create the herd of sheep, and press GO to start steering the herd northwards.

The sheep herd sliders are on the left side, the sliders on the right side deal with the steering strategies and the interactions between the dog and the sheep herd.

With the default settings for the sliders, the herd will be sucessfully steered to the north side of the world by a single dog. However, you can play with them to get variations:

- FEAR OF DOGS : This is the magnitude of the flight depacement. This will create more disruptions in the herd and make the trajectory to the north be more erratic and even impossible.
- NUMBER OF DOGS used to steer the herd
- FLIGHT ZONE is the maximum distance froma sheep to a dog that is causing a flight reaction
- FORCE OF COHESION is the distance that each sheep can see 360 degrees around it.
- STEERING STRATEGY: can be "line formation", "arc formation" or "side to side"


There are no random numbers used in this model.

A single dog is able to steer sucessfully even if we increase the herd size as long as the fear is not too high and the force of cohesion high.

When we start increasing the fear to its maximal value, the dogs movements are too siruptive and do not ucesfully steer the herd. Using a side-to-side running strategy or increasing the number of dogs using an arc formation helps.

If the cohesion is very small, the herd tends to split in smaller sub-herds, the arc formation grealky helps to gather the herd but is not strong enough to steer northwards.


Increase the fear
Decrease the cohesion
Increase the number of dogs
Change the steering strategy


Be able to start from a random sheep formation and gather it into a single herd before starting steering. Several strategies are proposed in the "Ben Buckley disseration"

Make the sheep move around obstacles in the middle of the world.

Model different emotional sheep reaction to the fear stress. Fear may last longer than teh time it takes to get out of the flight zone

Make some sheep different from the others: Heavier, leaders versus followers

Steer the herd to a specific goal point, not only a direction.

Try turn steering strategies when the herd is not moving to the direction of the goal


The word is configured not to wrap. This is due to the fact that we use average and standard-deviation calculations to calylate the centroid and the steering point, these calculations are not possible in a toroidal wrapped world.


* Flocking
* Moths
* Flocking Vee Formation
* Flocking - Alternative Visualizations


The behavior of a sheep herd is adapted from the bird flocking model available within the Netlogo libraries (see Biology > Flocking) which itself is based on the Boid algorithm by Reynolds [1987].

The herd steering stategies used by sheepdogs in this model are inspired from notions explained in "Modelling Sheep Flock Interaction with Sheepdogs" [Ben Buckley , 2008, University of Bath] and also in "Solving the Shepherding problem, heuristics for herding autonomous agents" [ Strombom, 2014, University of Uppsala]


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

* Wilensky, U. (1998). NetLogo Flocking model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Please cite the NetLogo software as:

* Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.


Copyright 1998 Uri Wilensky.

![CC BY-NC-SA 3.0](

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2002.

<!-- 1998 2002 -->

(back to the NetLogo User Community Models)