1D variant of the pedestrian model from
Baglietto & Parisi (2011).
Initialize agents on lines with random $x$ coordinate, and random direction $\vec{e}_\text{target}$ (left/right).
Agent color represents their intrinsic maximum speed $v_{d,\text{max}}^i$, which
is fixed per agent at a value uniformly sampled between $v_{d,\text{max}}$ and $v_{d,\text{max}} + \Delta v$.
Every step, we:
Find contacts and compute ve:
Agents on the same line are in "contact" if their x coordinates are
within distance $r^i + r^j$.
An agent $i$ which has other agents $j$ in contact gets
an escape velocity $\vec{v}_e^{ij}$ directed away from the average
positions of its contacting neighbors $j$. The magnitude of $\vec{v}_e$ is equal to the
$v_{d,\text{max}}^i$.
1D addition: in every time step where agents are in contact, they can switch their
preferred direction $\vec{e}_\text{target}$ to the direction of their escape velocity $\vec{v}_e^{ij}$
with probability $p_\text{switch}$.
Update radii:
Agents $i$ in contact with other agents get radius $r^i = r_\text{min}$.
When agents are not in contact, their radius increases with amount
$\Delta r = \frac{r_\text{max}}{\tau / \Delta t}$ per time step, until
its max radius $r_\text{max}$ is reached. Here, $\tau$ is a constant (0.5 sec)
and $\Delta t = \frac{r_\text{min}}{2*\text{max}(v_{d,\text{max}})}$
Small filled circles reflect $r_\text{min}$ (with color reflecting
the agent's $v_{d,\text{max}}^i$). Red circles reflect the current $r^i$.
Update positions:
Agents with contacts have velocity vector $\vec{v}^i = \vec{v}_e^{ij}$ (escape velocity) as defined above.
Agents with no contacts have velocity $\vec{v}^i = \vec{v}_d^i$,
with direction $\vec{e}_\text{target}$ and magnitude:
$v_d^i = v_{d,\text{max}}^i \cdot [ \frac{r^i - r_\text{min}}{r_\text{max} - r_\text{min}} ]^\beta$
(where $\beta = 0.9$)
Update each position: $x^i(t) = x^i(t-\Delta t) + \vec{v}^i(t)\Delta t$