Algorithm for movement.

Also, modified painting to show movement range.