Every grid cell holds a movement resistance r (1 = open habitat, up to 50 = a near-impassable barrier), generated from layered noise plus scattered barrier blobs -- the same kind of resistance surface used in real conservation GIS tools. Unlike the 3D version of this sim (which solves Kirchhoff's law directly by relaxing a voltage field, and finds the least-cost path with Dijkstra), this 2D model computes everything from a live swarm of biased random walkers shuttling between the two habitat-patch anchors:
step probability P(i to j) = g_ij / sum_k g_ik, g_ij = 2/(r_i+r_j)
corridor / flow = which cells the swarm actually wears a path through
effective resistance: by the random-walk / electrical-network duality
(Doyle & Snell 1984; Chandra et al. 1996):
C(S,D) = 2*M*R_eff(S,D)
C = mean round-trip commute time (steps), M = total conductance of all edges
A walker takes a step to one of its (up to 4) neighbours with probability proportional to the edge conductance -- easy, low-resistance ground is crossed often, barriers are crossed rarely. Every cell a walker passes through accumulates a visit count; over thousands of steps that count converges to the same corridor and current-flow picture the 3D version gets by solving a PDE, because the two are mathematically dual descriptions of the same resistor network (this duality is verified numerically in the accompanying test script: independent random-walk and relaxation solutions agree to within 0.2% on the same network). The chart below tracks the running effective-resistance estimate as more round trips complete -- watch it settle as the sample count grows.
- Barrier density + Regenerate — builds a new resistance surface and restarts the walker swarm from scratch.
- Corridor sensitivity — widens or narrows which cells count as "the corridor" (visit-frequency threshold, live, no restart needed).
- Walker swarm speed — how many steps per frame each walker takes; faster convergence, same underlying process.
- Random-walk flow — colors cells by net traffic in the source-to-destination direction only, the empirical analogue of a current-flow map.