swift playground question; roll right roll left


Loki.Mephisto

macrumors 6502a
Not sure where it exactly does that and what behaviour you expect. Could you provide more information?

My code is a bit different than yours, and since I'm on the beta the code won't run any more, so I cannot try your code.

Anyway: Is it possible your issue is because of using the loop:

while !isOnOpenSwitch ?

This causes Byte to try wo walk forever. I therefore used a for (for i in 1 ... 14) loop instead, so Byte stops once the's walked the scene
 
Last edited:

Loki.Mephisto

macrumors 6502a
Yes probably but why? It is on the open switch :(
Because it never leaves the inner loop it seems: once in the final row, after turnLeft, its stuck in the inner loop (while isBlockedLeft || isBlockedRight) because it is blocked to the right, so it never leaves the loop and therefore moves forward infinitely...

So I believe I have to correct my first post: the issue is not necessarily caused by the outer loop, but rather in the inner loop, never leaving it once in the final row
 
Last edited: