The black cubes find their way around. They always move forward but if they run into an obstacle they search for the quickest way around and then simply carry on.