I cannot replicate the message nor can I see anything amiss with the code (other than AppendTo
is not the most efficient way to go about this).
Here is one way to make the code more efficient.
x = 0; y = 0;
{lstx, lsty} = Reap[For[i = 0, i < 100, i++,
{a, b, c} = RandomReal[1, {3}];
If[c < 0.5,
If[a > 0.5, x = x + 1, x = x - 1]; Sow[x, "lstx"],
If[b > 0.5, y = y + 1, y = y - 1]; Sow[y, "lsty"]
]], {"lstx", "lsty"}][[2, All, 1]]
(* Out[44]= {{-1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1,
2, 1, 2, 1, 2, 1, 0, -1, 0, -1, 0, 1, 2, 3, 2, 3, 4, 5, 6, 5, 4, 3,
2, 1, 0, -1, 0, 1}, {-1, -2, -1, -2, -1, -2, -1, 0, 1, 2, 1, 2, 3,
2, 1, 2, 3, 2, 3, 4, 3, 4, 3, 2, 1, 2, 1, 0, 1, 2, 1, 2, 3, 4, 3, 4,
5, 6, 7, 6, 7, 6, 5, 4, 3, 2, 1, 2, 1, 0, -1, 0, -1}} *)
One could make further improvements but they would be more for elegance (whatever that means) than speed.