Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 4

Can You Spot the Sheep?

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?

The Fiddler, Zach Wissner-Gross, May 29, 2026(original post)

Solution

A sheep with a 180-degree field of view sees exactly the open half-plane in front of it. Whatever the two positions are, the direction from sheep 1 to sheep 2 is some fixed ray; sheep 1’s gaze is uniform on the circle and independent of the positions, so sheep 2 lies in sheep 1’s half-plane with probability exactly 12\tfrac12. The same holds for sheep 2, independently, so Pr(both see each other)=1212=14,\Pr(\text{both see each other}) = \tfrac12 \cdot \tfrac12 = \boxed{\tfrac14}, and the pen shape is a red herring.

The computation

Place two sheep at random points, give each a random gaze direction, and check that each one’s target lies in its forward half-plane (positive dot product with the gaze). The mutual-sight rate is 14\tfrac14.

import numpy as np
n = 10**7
rng = np.random.default_rng(1)
p, q = rng.random((n, 2)), rng.random((n, 2))        # the two sheep
ha, hb = rng.uniform(0, 2*np.pi, (2, n))             # gaze directions
v = q - p
sees1 = np.cos(ha)*v[:, 0] + np.sin(ha)*v[:, 1] > 0
sees2 = np.cos(hb)*v[:, 0] + np.sin(hb)*v[:, 1] < 0
print((sees1 & sees2).mean())  # 0.2500...

Extra Credit

Now three sheep are at three random points inside the square pen, staring in three random directions, each with a 180-degree field of view. What is the probability that all three sheep see each other?

Solution

Condition on the three positions, which form a triangle with angles AA, BB, CC. Sheep 1 must see both others: its half-plane must contain two rays separated by the angle AA at its vertex, which happens for an angular measure πA\pi - A of gaze directions, so the conditional probability is (πA)/(2π)(\pi-A)/(2\pi), and likewise for the others. Hence Pr=E[(πA)(πB)(πC)]8π3,\Pr = \frac{\mathbb{E}\bigl[(\pi - A)(\pi - B)(\pi - C)\bigr]}{8\pi^3}, the expectation over triangles of three uniform points in the square. It has no neat closed form; simulation gives Pr=0.02721\Pr = \boxed{0.02721} (about 1 in 37). The pen’s shape now matters, through the triangle-angle distribution. (The source’s value is behind its paywall; this is my own.)

The computation

Skip the angle formula and simulate the experiment directly: drop three sheep at random points, give each a random gaze, and count how often every sheep’s forward half-plane holds both of the others.

rng = np.random.default_rng(0); tot = N = 0
for _ in range(40):
    n = 5_000_000
    P = rng.random((3, 2, n)); H = rng.uniform(0, 2*np.pi, (3, n))
    g = np.stack([np.cos(H), np.sin(H)])             # (2, 3, n) gaze vectors
    def sees(i, j):                                  # sheep i sees sheep j
        v = P[j] - P[i]; return g[0, i]*v[0] + g[1, i]*v[1] > 0
    allsee = (sees(0, 1) & sees(0, 2) & sees(1, 0)
              & sees(1, 2) & sees(2, 0) & sees(2, 1))
    tot += allsee.sum(); N += n
print(round(tot/N, 5))     # ~0.02721