Tawaf is the Islamic ritual of walking counterclockwise around the Kaaba seven times (one full Tawaf = 7 ashwat/circuits). This sim places pilgrims on seven concentric rings around a central cube and moves each one along its ring, but the walking speed is not constant — it follows the same pedestrian fundamental diagram used to model real crowd flow at the Mataf:
v(ρ) = v_free · max(1 − ρ/ρ_jam, 0.05)
ρ = local crowd density (people / m²), measured per
ring-sector cell each frame: count / (arc-length × ring-width)
v_free = free-flow walking speed you set
ρ_jam = density at which the crowd effectively grinds to
a crawl (a Greenshields-style linear speed-density law)
Each pilgrim's angular speed is ω = v(ρ)/r, so pilgrims on outer rings (larger r) sweep a slower angular rate for the same linear speed. When a pilgrim's accumulated angle reaches 7 full turns, that Tawaf is recorded as complete and they are re-seeded onto a fresh ring to keep the crowd flowing continuously.
- Pilgrims — total agent count; more agents packed onto the same seven rings raises local density.
- Free-flow speed — the speed each pilgrim would walk in an empty plaza.
- Jam density — how much personal space real crowd-control barriers and marshalling leave per person before flow chokes; lower it to see gridlock form near the Kaaba's corners.
- Density heatmap — colors each pilgrim from blue (free-flowing) to red (jammed) by the local density they are currently experiencing.
Real-world relevance: this is the same density-speed relationship crowd-safety engineers use to plan the Hajj Mataf's ring capacity and barrier spacing, where the 2015 Mina crush made this exact congestion physics a matter of public-safety engineering.