Sheep That See Each Other
A Fiddler puzzle on mutual visibility: sheep at random points in a square, facing random directions, each with a 180-degree field of view. Two sheep see each other with probability 1/4 whatever the pen; for three, the probability reduces to an average of (pi - alpha)(pi - beta)(pi - gamma) over the triangle's angles and comes to about 0.0272, with a Monte Carlo check.
Problem
Two sheep are at two random points inside a square pen. They are munching grass and staring in two random directions. Each sheep has a field of view that’s 180 degrees. What is the probability that they both see each other?
Extra credit. Now, three sheep are at three random points inside a square pen. They are munching grass and staring in three random directions. As before, each sheep has a field of view that’s 180 degrees. What is the probability that all three sheep see each other?
Credit: The Fiddler on the Proof.
What it means to see
Each sheep stands at a point chosen uniformly in the unit square and faces a direction chosen uniformly on the circle, independently of everything else. A field of view of means the sheep sees the entire half-plane in front of it: the half whose boundary runs through the sheep at right angles to its facing direction. In vectors, a sheep at facing the unit vector sees a point exactly when lies forward of that boundary,
Two sheep
Fix the two positions and for a moment and look only at the directions. Sheep sees sheep when its facing vector points into the half-plane containing , that is, when the facing direction lies within of the direction from to . Those facing directions fill exactly half of the circle, and the facing direction is uniform, so Crucially this does not depend on where and are: wherever sits, half of ‘s possible facings point towards it. By the same argument . The two facings are independent, so The positions never entered the calculation, so the square is a red herring: the answer is for a pen of any shape.
Three sheep: each must see two
With three sheep the directions still do all the work, but now each sheep has to see two others at once. Consider sheep , and let be the interior angle at in the triangle , the angle between the direction to and the direction to . Sheep sees when its facing lies in the half-circle of directions centred on , and sees when its facing lies in the half-circle centred on . To see both, the facing must lie in the overlap of these two half-circles.
Two half-circles whose centres are apart overlap in an arc of . (Slide one half-circle round by and it loses exactly of its overlap with the other.) Since the facing is uniform, writing in radians. The same holds at and with their interior angles and .
Averaging over the triangle
Each sheep’s success depends only on its own facing, and the three facings are independent. So, with the positions fixed, Because , each factor is the sum of the other two angles, , and the same identity expands the product neatly: What remains is to average this over the triangle made by three uniform points in the square, The distribution of the angles of a random triangle in a square has no tidy closed form, so this last expectation is evaluated numerically. To high precision, that is, about . The factor vanishes whenever one angle approaches , so the long, thin triangles that three random points so often make contribute almost nothing, which is why the answer sits well below the value that a perfectly equilateral pen would give.
| Quantity | Value |
|---|---|
Computational verification
We confirm both answers by simulation: place the sheep uniformly, draw their facings uniformly, and test the half-plane condition for every ordered pair. This uses nothing but the raw rule of the problem, no angles and no formula, so it checks the whole argument independently. As a faster cross-check, which assumes the step rather than testing it, we also average the per-triangle formula , with the directions already integrated out.
import numpy as np
rng = np.random.default_rng(20260529)
N = 20_000_000
def dirs(n): # uniform facing directions
t = rng.uniform(0, 2*np.pi, n)
return np.stack([np.cos(t), np.sin(t)], -1)
def sees(P, u, Q): # viewer at P facing u sees Q?
return ((Q - P) * u).sum(-1) >= 0
# two sheep
A, B = rng.uniform(0,1,(N,2)), rng.uniform(0,1,(N,2))
both = sees(A, dirs(N), B) & sees(B, dirs(N), A)
print(both.mean()) # -> 0.2500
# three sheep
A, B, C = (rng.uniform(0,1,(N,2)) for _ in range(3))
uA, uB, uC = dirs(N), dirs(N), dirs(N)
allsee = (sees(A,uA,B) & sees(A,uA,C) &
sees(B,uB,A) & sees(B,uB,C) &
sees(C,uC,A) & sees(C,uC,B))
print(allsee.mean()) # -> 0.0272
| Quantity | Exact / formula | Monte Carlo |
|---|---|---|
| two sheep | ||
| three sheep |
A pen where the answer is exact: the circle
The square resists a closed form because the angles of a random triangle inside it have no tractable distribution. One pen escapes this: a circular fence with the sheep on the rail. Three points on a circle make a triangle inscribed in it, and inscribed triangles pin the angles down exactly.
The angles are half the opposite arcs
Fix the circle’s centre . The inscribed-angle theorem says the interior angle at a vertex is half the central angle standing on the same chord. At this is , the central angle of the arc opposite .
Write for the central angle of the arc opposite , and likewise . Then The three opposite arcs tile the circle, , which simply re-derives .
The arcs are uniform on the simplex
The three points are independent and uniform on the circle. By rotational symmetry we may hold one of them fixed; the other two are then uniform on the cut circle, an interval of circumference . The three arcs are exactly the gaps left by two uniform points on that interval, and the gaps of uniform points on an interval are uniformly distributed over the simplex of fractions that sum to one. With , the three normalised arcs, and hence the normalised angles are uniform over the triangle .
Two integrals
On that triangle the density is constant. The triangle has area , so the density is . Writing and integrating over , the inner integrals being and . By symmetry .
Assembling the answer
For any pen, the per-triangle probability is . In normalised angles , so this is using with . Taking the expectation over the uniform-simplex angles, The independent direction-level simulation, with the sheep placed on the circle and their facings drawn at random, gives , in agreement.
A round pen is therefore a little kinder to mutual sightlines than a square one, against the square’s . Points on a rim never fall almost in a line, so the triangles stay fatter, the binding overlaps stay larger, and the product survives more often. Two sheep, as always, see each other with probability exactly , on a pen of any shape at all.