So, a particle will exchange its velocity (dx, dy, dz) with every other particle. That means that when you finish one cycle of exchanges, a particle will retain the velocity of the last particle it happened to interact with. The order of the interaction can make quite a difference, then. I would say, the FOR EACH doesn't give you a very fine control over the order in which the particles interact. Perhaps you should use an array to have a better control over this order of exchanges.
>Every monad has an X, Y, and Z, plus a change in X, Y, and Z.
>
>The rules are that first every monad updates its X, Y, and Z based on its dX, dY, and dZ.
>
>Then, the monad exchanges its trajectories with every other monad. Here's the relevant code:
>
>
> procedure DoStuff
>
> * move inertially
> this.nX = this.nX + this.nDx
> this.nY = this.nY + this.nDy
> this.nZ = this.nZ + this.nDz
>
> * see if there's anything to interact with
> for each oB in oAbsoluteMatter
> lnDx = oB.nDx
> lnDy = oB.nDy
> lnDz = oB.nDz
> oB.nDx = this.nDx
> oB.nDy = this.nDy
> oB.nDz = this.nDz
> this.nDx = lnDx
> this.nDy = lnDy
> this.nDz = lnDz
> endfor
>
> endproc
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)