The simulation tracks idealised “ants” moving inside a unit square. Each ant travels at unit speed in a straight line until it collides with another ant’s path, another ant, or the boundary. Collisions are perfectly elastic: the velocity vector is reflected across the line of impact, so the ant continues with the same speed but a mirrored direction.
Instead of advancing all ants in fixed time steps, the engine jumps directly between future collision events. For every ant we keep its current position, start time, velocity, and the list of straight-line segments it has already traversed. Whenever an event occurs, a new segment is recorded and the ant’s state updates to the collision point.
m segments of an ant. If the
average drops below this value, the ant becomes inactive and no longer participates in new collisions.