This is a very orthogonal patch to bb's D3021 / D2837 or my D3179 / D2913.
The problem with dancing is that units perfectly predict the target's position given its velocity, but that velocity has a probability of changing.
This makes the unit account for that, by keeping tracks of how many attacks failed, and after enough misses, reverts to a probabilistic model.
On the test map below, with svn, the cavalry never dies. With the patch, it takes 30-60 seconds.