A description of the RotorRouter Algorithm

The program will drop a grain of sand at the center cell in the n X n grid. Initially all the cells are pointed in the up direction. Everytime a grain of sand touches a cell the arrow the cell is pointing rotates clockwise. Grains of sand are routed via the direction of the cell arrow. Note a grain of sand is routed first then the arrow changes direction. A grain of sand moves until it finds a empty cell.

What do the colors mean:

If a cell is empty is has the color white

If a cell is occupied and the arrow is pointing in the 'up' direction it has the color black

If a cell is occupied and the arrow is pointing in the 'right' direction it has the color red

If a cell is occupied and the arrow is pointing in the 'down' direction it has the color green

If a cell is occupied and the arrow is pointing in the 'left' direction it has the color blue

Colors are displayed after a grain of sand has moved into an unoccupied cell.