Click green flag to start. Press space bar to reset.
Ok, nothing fancy - just used loops to repeat whenever possible. Added thought bubbles at points to explain where the bug is going next.