I am new to mathematica, and I have this 3d random walker program which runs with a fixed (given) amount of steps. What I want it to do is to run forever but stop when two walkers collide (aka have the same position). When it stops it should return the number of steps before the collision. So I am planning on having that function to be in loop which in Java/C might look similar to this:
for (i = 0; i < times_to_run; i++) { total = total + randomWalker(args..); } Clear[randomWalk3D] randomWalk3D[steps_Integer, start_, region_] /; start \[Element] region := ... x = 0; v = {}; For[i = 1, i < steps, i++, If[{positions[[i]]} == {positions2[[i]]}, x++; AppendTo[v, i],] ] Manipulate [ Graphics3D[{Opacity[0.5, Gray], region, AbsolutePointSize[10], Cyan, Line[positions], Red, Line[positions2], pointPrimitives[i], pointPrimitives2[i]}, text[i], ImagePadding -> 5, Lighting -> {{"Ambient", Gray}}], {i, 1, Length[positions], 1}] Print["Number of collisions: ", x] Print["Collision at i = ", v] ] randomWalk3D[1000, {4, 4, 4}, Cuboid[{0, 0, 0}, {10, 10, 10}]] 
