Night Fold

You are a sheepdog. Bring the sheep into the fold before the night. A sheep runs away from you, so come from the far side of the flock. At night, wolves come and take the sheep that are outside the fold.

Connecting
Sheep Sheep in the fold The dog Wolves Fence The fold

Bring the sheep into the fold through the opening in its fence.

Use the arrow keys or W, A, S and D to move. Hold Shift to run. Collect the sheep into one flock first: one flock is easier to move than many small ones. Then walk behind the flock, away from the opening.

One boid moves a flock

The dog does not push a sheep. Each sheep is a gen_boid process that flees from the dog that it sees (the rule flee with the target {group, dog}), and stays near the other sheep. So the flock moves away from the dog.

A flock is not a sheep

No sheep knows the flock. The reading "Flocks" comes from boids:flocks/2: the groups of sheep that see each other. A scattered flock is harder to move.

A boid changes its group

A sheep that comes into the fold has the group penned and other rules: it stays inside. A wolf hunts only the group sheep, so a sheep in the fold is safe.

A wolf sends a message

A wolf that touches a sheep sends taken to the process of the sheep. The sheep tells the director of the field, and stops. The world removes a boid that stops.

Read the code of the game.