ex3 of robot programming http://www.cs.bham.ac.uk/internal/courses/robot-prog/current/ex3.php