click and watch
The beetle does it like Langton's Ant: At black switch to white, turn left and go. Else switch to black, turn right and go look at: http://scratch.mit.edu/projects/20660239/