Simulating

Walk to the matrix's boarder and then change the direction in the order of left, down, right and up.