This is a basic algorithm we made to compete in Roborrego's Candidates Competition 2017.
We created a robot that could detect black lines and aovid them, go through a maze and detect colors, and push a ball in a green carpet towards the goal by detecting the ball (using its color and position to distinguish it from walls), all while the robot navigated straight (constatnly aligning itself with walls using distance sensors)