It follows the simple rule of black = turn right, white = turn left, and whenever it walks out of a square it flips the color of it.